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.
Comment #1 by k.hara.pg — 2012-07-23T21:40:32Z
Comment #2 by github-bugzilla — 2012-08-24T06:06:40Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/28d78922f17ce2380340770488338da1fe9cad0c fix Issue 8410 - Static initializers for fixed size arrays too https://github.com/D-Programming-Language/dmd/commit/0ef718025a42f6912ff9acc15ad7ba7a5f1b554c Merge pull request #1063 from 9rnsr/fix8410 Issue 8410 - Static initializers for fixed size arrays too