Bug 16245 – the message emitted when a const function mutates members is misleading
Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-07T07:50:00Z
Last change time
2017-03-22T12:21:07Z
Assigned to
nobody
Creator
b2.temp
Comments
Comment #0 by b2.temp — 2016-07-07T07:50:50Z
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"
Comment #1 by github-bugzilla — 2017-01-14T21:26:53Z