October 18, 2013 [Issue 11292] New: Cannot re-initialize a const field in postblit | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11292 Summary: Cannot re-initialize a const field in postblit Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: samukha@voliacable.com --- Comment #0 from Max Samukha <samukha@voliacable.com> 2013-10-18 05:54:29 PDT --- struct S { immutable int x; this(int x) { this.x = x; } this(this) { x = 1; } } void main() { S s = S(1); S s2 = s; } Error: can only initialize const member x inside constructor Postblit is a constructor. Why re-initialization is allowed for the state copied from .init and not for the state copied from the source struct? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 22, 2013 [Issue 11292] Cannot re-initialize a const field in postblit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=11292 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-21 21:11:33 PDT --- (In reply to comment #0) > struct S > { > immutable int x; > > this(int x) > { > this.x = x; > } > > this(this) { > x = 1; > } > } > > void main() { > S s = S(1); > S s2 = s; > } > > Error: can only initialize const member x inside constructor > > Postblit is a constructor. Why re-initialization is allowed for the state copied from .init and not for the state copied from the source struct? This is definitely a compiler bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation