Bug 5214 – Compiler crash with array of empty {}

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-11-13T14:43:00Z
Last change time
2010-12-05T00:27:23Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
bearophile_hugs

Comments

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);
Comment #2 by bugzilla — 2010-12-05T00:27:23Z