Thread overview
[Issue 7685] New: Cannot initialize const field if field initializer present
Mar 11, 2012
Andrej Mitrovic
Mar 11, 2012
Andrej Mitrovic
Dec 27, 2012
Andrej Mitrovic
Dec 28, 2012
Kenji Hara
March 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7685

           Summary: Cannot initialize const field if field initializer
                    present
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-03-11 08:29:55 PDT ---
struct Foo
{
   int val = int.init;
   this(inout(int) nval) inout {
       this.val = nval;
   }
}

test.d(18): Error: cannot modify const/immutable/inout expression this.val

You can try with 'const', the results are the same. Also, the same thing happens if the field initializer is 'void'. So even if the above should be legal, I think it should be allowed if the field initializer is void.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7685



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-03-11 08:31:29 PDT ---
(In reply to comment #0)
> So even if the above should be
> legal, I think it should be allowed if the field initializer is void.

Sorry, that should read 'even if the above should be illegal'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7685


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-27 09:21:00 PST ---
Seems to be fixed in 2.061.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7685


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WORKSFORME


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------