[Issue 11292] Cannot re-initialize a const field in postblit

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 21 21:11:36 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11292


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg at 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: -------


More information about the Digitalmars-d-bugs mailing list