Thread overview
Can't evaluate enum at compile time
Feb 04, 2011
Andrej Mitrovic
Feb 04, 2011
bearophile
Feb 04, 2011
bearophile
Feb 04, 2011
Andrej Mitrovic
February 04, 2011
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?
February 04, 2011
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
February 04, 2011
> I will file it in bugzilla:

http://d.puremagic.com/issues/show_bug.cgi?id=5524
February 04, 2011
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!