Comment #0 by bearophile_hugs — 2010-11-13T14:43:21Z
This D2 program crashes DMD 2.050:
auto foos = [{}];
void main() {}
Comment #1 by clugdbug — 2010-11-13T18:22:30Z
PATCH: declaration.c, line 751.
init->toExpression returns NULL if it fails. (BTW this is case where non-nullable types would catch a bug <g>. Although it was trivial to track down, it's lain hidden in the code for ages).
Give it the same error message as happens in D1.
if (ai->isAssociativeArray())
e = ai->toAssocArrayLiteral();
else
e = init->toExpression();
+ if (!e)
+ {
+ error("cannot infer type from initializer");
+ e = new ErrorExp();
+ }
init = new ExpInitializer(e->loc, e);
type = init->inferType(sc);