struct A { static A a; alias a this; } void foo(A a) { } void main() { foo(A); } Results in a stack overflow using latest git. No overflow with 2.052.
For me this prints: TypeExp::toElem() testx.d(13): Error: type A is not an expression on win32. So it seems to be fixed, unless it is platform specific. Please reopen if so. dmd 2.054
Works for me now.
It isn't fixed. struct A { static A a; alias a this; } void foo(A a) { } void main() { // foo(A); // Error: type A is not an expression int s = A; // Error: type A has no value + stack overflow }
*** Issue 6030 has been marked as a duplicate of this issue. ***
caused by mtype.c: // 'from' is A and 'to' is int static MATCH aliasthisConvTo(AggregateDeclaration *ad, Type *from, Type *to) { assert(ad->aliasthis); Declaration *d = ad->aliasthis->isDeclaration(); if (d) { assert(d->type); Type *t = d->type; // <-- gets struct type A again if (d->isVarDeclaration() && d->needThis()) { t = t->addMod(from->mod); } ... MATCH m = t->implicitConvTo(to); Guess it should be caught earlier though.
> int s = A; // Error: type A has no value + stack overflow I still can't reproduce this. What version/os?
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8ba1ff182f138ce21bb83fc9868b35f6b0e2b361 add test case for Issue 6029 - Regression(2.053): DMD stack overflow with invalid alias this
I couldn't reproduce it, but I added it to the test suite.