D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7094 - More initializers than struct fields for static member creation
Summary: More initializers than struct fields for static member creation
Status: RESOLVED DUPLICATE of issue 7742
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 minor
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-12-11 02:32 UTC by bearophile_hugs
Modified: 2012-03-25 13:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-12-11 02:32:31 UTC
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 bearophile_hugs 2012-03-25 13:23:16 UTC

*** This issue has been marked as a duplicate of issue 7742 ***