Thread overview
[Issue 2506] New: Can't initialize const member in ctor if it is accessed via this.member syntax
Dec 10, 2008
d-bugmail
Dec 11, 2008
d-bugmail
Dec 12, 2008
d-bugmail
Dec 25, 2008
d-bugmail
December 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2506

           Summary: Can't initialize const member in ctor if it is accessed
                    via this.member syntax
           Product: D
           Version: 2.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: 2korden@gmail.com


struct Integer
{
    this(int i)
    {
        this.i = i; // fails: Error: this.i is not mutable
    }

//  this(int ii)
//  {
//      i = ii; // ok, but I want member and argument names to match
//  }

    const int i;
}


-- 

December 11, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2506


gide@nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic




------- Comment #1 from gide@nwawudu.com  2008-12-11 03:54 -------
Both ctors do not compile in DMD 2.021. Also the error message doesn't have a line number, added diagnostic to keywords.

struct Integer {
  this(int ii) {
      i = ii; // Error: this is not mutable
  }
  const int i;
}


-- 

December 12, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2506





------- Comment #2 from 2korden@gmail.com  2008-12-11 20:59 -------
The bug was reported against DMD2.020 and it latter example *does* successfully compile. Must be a regression.


-- 

December 25, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2506


bugzilla@digitalmars.com changed:

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




------- Comment #3 from bugzilla@digitalmars.com  2008-12-25 04:42 -------
Fixed dmd 2.022


--