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