July 30, 2004
Shouldn't this be legal?

D:\code\d>type test.d
class A {}

int main()
{
static A a = new A();
return 0;
}

D:\code\d>dmd test.d
test.d(5): non-constant expression new A


July 30, 2004
"Sean Kelly" <sean@f4.ca> wrote in message news:cee7bb$mf$1@digitaldaemon.com...
> Shouldn't this be legal?
>
> D:\code\d>type test.d
> class A {}
>
> int main()
> {
> static A a = new A();
> return 0;
> }
>
> D:\code\d>dmd test.d
> test.d(5): non-constant expression new A

No, all static initializers need to be resolvable at compile time. To do run time initialization, use a static constructor.