This is wrong D2 code: int foo() { assert(.r == 0); return 0; } enum int r = foo(); void main() {} dmd 2.043 shows a good enough error message (even if there's no need to print the second error two times): test.d(2): Error: circular reference to 'r' test.d(5): Error: cannot evaluate foo() at compile time test.d(5): Error: cannot evaluate foo() at compile time This is another wrong D2 program: int foo() { return r; } enum int r = foo(); void main() {} But this time dmd 2.043 shows: Stack overflow
This looks similar to bug 2315, but I suspect the cause may be quite different.
Fixed a couple of releases ago. Now on both D1 and D2, it displays a message like: bug.d(42): Error: function bug.foo CTFE recursion limit exceeded bug.d(43): called from here: foo() bug.d(42): 1000 recursive calls to function foo bug.d(45): called from here: foo() and the first case doesn't have a repeated error message, it now displays: bug.d(47): Error: cannot evaluate foo() at compile time. Circular reference? bug.d(43): while evaluating r.init bug.d(47): called from here: foo()