[Issue 6355] New: Template constructor cannot initialize non-mutable field
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 20 02:22:29 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6355
Summary: Template constructor cannot initialize non-mutable
field
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-07-20 02:17:09 PDT ---
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
----
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list