www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16245] New: the message emitted when a const function mutates

https://issues.dlang.org/show_bug.cgi?id=16245

          Issue ID: 16245
           Summary: the message emitted when a const function mutates
                    members is misleading
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

For

struct Foo
{
    int i;
    void foo() const{i = 1;}
}

DMD outputs

 Error: cannot modify immutable expression this.i
which can be interpreted as "i is const". The error message should rather be "Error: cannot modify %s in const function" --
Jul 07 2016