Bug 8410 – Static initializers for fixed size arrays too
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-22T06:22:00Z
Last change time
2012-08-24T09:32:15Z
Keywords
pull
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-07-22T06:22:17Z
struct Foo { int[15] x; string s; }
void main() {
Foo[5] a1 = Foo([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "hello"); // OK
Foo f = { s: "hello" }; // OK (not static)
Foo[5] a2 = { s: "hello" }; // error
}
DMD 2.060alpha gives:
temp.d(5): Error: a struct is not a valid initializer for a Foo[5u]
temp.d(5): Error: variable temp.main.a2 is not a static and cannot have static initializer
I'd like the third syntax too to work, because it saves me to specify all the struct fields, like the x array.