www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can't evaluate enum at compile time

reply Andrej Mitrovic <none none.none> writes:
import std.path : join;

enum rootdir = r"C:\Path\";
enum testdir = join(rootdir, "simple"); 

void main() { }

enumBug.d(4): Error: variable __arrayArg774 is used before initialization
enumBug.d(4): Error: cannot evaluate
join("C:\\Path\\","simple",(const(char)[][0u] __arrayArg774 = void;
 , cast(const(char)[][])__arrayArg774)) at compile time
enumBug.d(4): Error: cannot evaluate
join("C:\\Path\\","simple",(const(char)[][0u] __arrayArg774 = void;
 , cast(const(char)[][])__arrayArg774)) at compile time

std.path is supposed to work on strings, it doesn't touch std.file at all. Why
can't it run at compile time?
Feb 04 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Andrej Mitrovic:

 std.path is supposed to work on strings, it doesn't touch std.file at all. Why
can't it run at compile time?

Most of Phobos is written in D, and D distributions contain full source code, so in similar cases you just need to take a look at the sources of Phobos and do some experiments to locate the problem. It seems your problem is caused by a CTFE bug, I will file it in bugzilla: int foo(int x, int y, int[] more...) { return 0; } enum r = foo(0, 0); void main() {} Bye, bearophile
Feb 04 2011
parent bearophile <bearophileHUGS lycos.com> writes:
 I will file it in bugzilla:

http://d.puremagic.com/issues/show_bug.cgi?id=5524
Feb 04 2011
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 2/4/11, bearophile <bearophileHUGS lycos.com> wrote:
 Most of Phobos is written in D, and D distributions contain full source
 code, so in similar cases you just need to take a look at the sources of
 Phobos and do some experiments to locate the problem.

Yeah. I was in the middle of something so I was too lazy to go figure it out on my own, hence I posted it here. :)
 It seems your problem
 is caused by a CTFE bug, I will file it in bugzilla:

Thanks!
Feb 04 2011