[Issue 10672] New: struct initializer treated as lambda literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 19 04:29:46 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10672
Summary: struct initializer treated as lambda literal
Product: D
Version: D1 & D2
Platform: All
OS/Version: All
Status: NEW
Severity: minor
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: public at dicebot.lv
--- Comment #0 from Dicebot <public at dicebot.lv> 2013-07-19 04:29:45 PDT ---
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++.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list