← Back to index
|
Original Bugzilla link
Bug 6691 – static constructor inside template cannot initialize immutable template members
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-09-18T18:43:00Z
Last change time
2011-09-21T00:02:26Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0
by k.hara.pg — 2011-09-18T18:43:52Z
Follwing should compile, but can't. template Hoge() { immutable static int[int] dict; immutable static int value; static this() { dict = [1:1, 2:2]; value = 10; } } alias Hoge!() H;
Comment #1
by k.hara.pg — 2011-09-18T19:24:31Z
https://github.com/D-Programming-Language/dmd/pull/392
Comment #2
by bugzilla — 2011-09-20T22:53:48Z
https://github.com/D-Programming-Language/dmd/commit/6fd9beafb3c7ff9dff71e3499ee404818d1e0aea
Comment #3
by bearophile_hugs — 2011-09-21T00:02:26Z
Keep in mind that there are cases more important than this one that currently don't work: struct Foo { immutable int[1] arr; this(int x) { arr[0] = 1; } } auto f = Foo(1); void main() {}