Bug 6355 – Template constructor cannot initialize non-mutable field

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-20T02:17:00Z
Last change time
2011-08-03T07:37:22Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2011-07-20T02:17:09Z
This is valid D2 code, but couldn't compile. ---- struct S { const int value; this()(int n){ value = n; } } void main() { S s = S(10); } ---- test.d(4): Error: can only initialize const member value inside constructor test.d(8): Error: template instance test.S.__ctor!() error instantiating ----
Comment #1 by k.hara.pg — 2011-07-20T03:04:48Z
Comment #2 by bugzilla — 2011-07-21T12:06:05Z
Comment #3 by yebblies — 2011-08-03T07:37:22Z
*** Issue 6427 has been marked as a duplicate of this issue. ***