[Issue 13905] New: calls to mutable methods are just ignored when instance is an enum
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Dec 28 03:44:50 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13905
Issue ID: 13905
Summary: calls to mutable methods are just ignored when
instance is an enum
Product: D
Version: unspecified
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: minor
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: kanael at weka.io
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;
}
--
More information about the Digitalmars-d-bugs
mailing list