TEST CASE:
-----
void bug4237()
{
int s;
with(typeof(s)) {}
}
----
PATCH (D2 svn 502):
// WithStatement::semantic. line 3639: segfaults because toDsymbol(sc)
// returns null.
{ TypeExp *es = (TypeExp *)exp;
- sym = es->type->toDsymbol(sc)->isScopeDsymbol();
+ Dsymbol *dsym = es->type->toDsymbol(sc);
+ sym = dsym ? dsym->isScopeDsymbol() : NULL;
if (!sym)
{ error("%s has no members", es->toChars());
body = body->semantic(sc);
return this;
}
}
Comment #1 by clugdbug — 2010-05-26T13:20:16Z
Darn it, waited to long before hitting submit, and another bug snuck in before this one -- test case should be changed to bug4238(). <g>.
Anyway, if you add one line to the patch, it fixes bug 1413. I was actually trying to generate a case where 1413 matters, but failed. But I found this case instead.
PATCH (D2 svn 502):
// WithStatement::semantic. line 3639: segfaults because toDsymbol(sc)
// returns null.
{ TypeExp *es = (TypeExp *)exp;
- sym = es->type->toDsymbol(sc)->isScopeDsymbol();
+ Dsymbol *dsym = es->type->toDsymbol(sc);
+ sym = dsym ? dsym->isScopeDsymbol() : NULL;
if (!sym)
{ error("%s has no members", es->toChars());
+ if (body)
body = body->semantic(sc);
return this;
}
}