Bug 10672 – (D1 only) struct initializer treated as lambda literal

Status
RESOLVED
Resolution
WONTFIX
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2013-07-19T04:29:00Z
Last change time
2013-07-24T01:11:05Z
Assigned to
nobody
Creator
public

Comments

Comment #0 by public — 2013-07-19T04:29:45Z
Confusing example that breaks "looks like C, acts like C" rule. ---------------------------- struct foo { int i; }; foo[] blah = [ { 1 }, { 2 } ]; // fine void main() { foo[] blah = [ { 1 }, { 2 } ]; // Error: array initializers as expressions are not allowed } ---------------------------- This probably happens because assigning a lambda literal has higher precedence in grammar than struct initializer. However, difference between global initialization with forced compile-time evaluation and normal initialization should be extremely confusing. Especially for people coming from C/C++.
Comment #1 by henning — 2013-07-23T15:47:39Z
I'm unable to reproduce it. Which platform are you on?
Comment #2 by lt.infiltrator — 2013-07-23T17:22:48Z
I can reproduce on http://dpaste.dzfl.pl/ only with D1; not with D2.
Comment #3 by public — 2013-07-24T01:11:05Z
Yeah, sorry for the fuss, must be inattention from my side. Closing.