Bug 11741 – Fields with void initializers cannot be cooked in constructors

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-14T10:58:00Z
Last change time
2013-12-14T11:06:09Z
Assigned to
nobody
Creator
jakobovrum

Comments

Comment #0 by jakobovrum — 2013-12-14T10:58:15Z
Example exhibiting the problem: --- class S { immutable int a = void; this() { a = 42; } } --- Error output: --- test.d(7): Error: cannot modify immutable expression a --- It compiles and works as expected without the void initializer. It's understandable behaviour for non-void initializers, but I think the void initializer should be treated as a special case; fields with void initializers should be considered uncooked in the constructor. The example might seem frivolous, but it's important when the field is a fixed-length array, for which void initializers can make a big difference.
Comment #1 by jakobovrum — 2013-12-14T11:06:09Z
(In reply to comment #0) > Example exhibiting the problem: > ... Sorry, this is a duplicate of #10643. *** This issue has been marked as a duplicate of issue 10643 ***