$ cat bla.d struct Foo { const x = Foo(); static Foo opCall() { return Foo.init; } } $ dmd bla.d ::mangle(x) dmd: mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' failed. Aborted Tested with dmd 1.061, where I removed the commented printf() in mangle.c line 37.
Probably related to bug 2080, since both involve type inference.
A partial fix: https://github.com/D-Programming-Language/dmd/commit/1fc2fdb5fa9831eee2e1cae518ad350d517717c4 The error message is now: test.d(2): Error: cannot implicitly convert expression (opCall()) of type Foo to Foo
Compiles without error on D1 (1.072) Give a forward reference error with D2 (2.058) struct Foo { enum x = Foo(); static Foo opCall() { return Foo.init; } } testx.d(5): Error: forward reference to type Foo testx.d(5): Error: cannot implicitly convert expression (Foo()) of type Foo to Foo
Seems to work now (compiles and runs with -main), though it does hit a deprecation warning: ----- test.d(2): Deprecation: variable test.Foo.x const field with initializer should be static, __gshared, or an enum -----
P.S. This is on git HEAD (post 2.066).
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c43a17582bdfb7c28980803c05663a5d09526557 fix Issue 4225 - forward reference of opCall (mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' failed.)