Merged DMD commit 645b5d8797768bced8db0c32dfa03e9290d0ced0:

5248 CTFE Segfault when calling a function on an enum struct

Fix the D1 version of this bug, which causes a stack overflow
rather than a segfault:
compiler inserts assert(this, "null this") whereas for D2 it is
assert(&this, "null this")
This commit is contained in:
David Nadlinger
2011-04-23 18:16:33 +02:00
parent 8ba89d5187
commit 2c0f68b5d2

View File

@@ -3102,7 +3102,7 @@ Expression *AssertExp::interpret(InterState *istate)
{ // Special case: deal with compiler-inserted assert(&this, "null this")
AddrExp *ade = (AddrExp *)this->e1;
if (ade->e1->op == TOKthis && istate->localThis)
if (ade->e1->op == TOKdotvar
if (istate->localThis->op == TOKdotvar
&& ((DotVarExp *)(istate->localThis))->e1->op == TOKthis)
return getVarExp(loc, istate, ((DotVarExp*)(istate->localThis))->var);
else
@@ -3111,7 +3111,13 @@ Expression *AssertExp::interpret(InterState *istate)
if (this->e1->op == TOKthis)
{
if (istate->localThis)
return istate->localThis->interpret(istate);
{
if (istate->localThis->op == TOKdotvar
&& ((DotVarExp *)(istate->localThis))->e1->op == TOKthis)
return getVarExp(loc, istate, ((DotVarExp*)(istate->localThis))->var);
else
return istate->localThis->interpret(istate);
}
}
e1 = this->e1->interpret(istate);
if (e1 == EXP_CANT_INTERPRET)