Bug 13905 – calls to mutable methods are just ignored when instance is an enum
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2014-12-28T11:44:00Z
Last change time
2015-06-09T01:31:17Z
Assigned to
nobody
Creator
kanael
Comments
Comment #0 by kanael — 2014-12-28T11:44:50Z
the following code compiles and runs, and prints '10' twice.
I expect it not to compile, since x is an enum.
If x is declared as 'immutable S', it does not compile.
import std.stdio;
struct S {
uint value;
void setValue(uint v) {
value = v;
}
}
int main() {
enum S x = S(10);
writeln(x);
x.setValue(20);
writeln(x);
return 0;
}
Comment #1 by andrej.mitrovich — 2014-12-31T17:24:03Z
*** This issue has been marked as a duplicate of issue 13904 ***