https://d.puremagic.com/issues/show_bug.cgi?id=11741
Summary: Fields with void initializers cannot be cooked in
constructors
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Jakob Ovrum <[email protected]> 2013-12-14 10:58:15 PST
---
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.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------