Bug 7094 – More initializers than struct fields for static member creation
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-12-11T02:32:00Z
Last change time
2012-03-25T13:23:16Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-12-11T02:32:31Z
D2 code:
struct Foo {
static f = Foo(0); // line 2
int x;
}
void main() {}
DMD 2.057beta refuses it, but I think it's correct code:
test.d(2): Error: more initializers than fields of Foo
Workaround: define 'f' after x:
struct Foo {
int x;
static f = Foo(0); // line 2
}
void main() {}
Comment #1 by bearophile_hugs — 2012-03-25T13:23:16Z
*** This issue has been marked as a duplicate of issue 7742 ***