the following code shows how one could mutate an immutable object:
struct Foo {
bool flag;
void flip() {
flag = true;
}
}
immutable Foo foo;
(&foo.flip)();
assert(!foo.flag); //fails
Comment #1 by hbaelx — 2016-07-27T22:41:28Z
It doesn't only break immutability, but also TLS:
struct Foo
{
void ping() shared {}
}
void main()
{
Foo a;
// a.ping(); // rejected
(&a.ping)(); // accepted
}
I really hope someone fixes this soon enough. This is a major flaw.
(In reply to Adam D. Ruppe from comment #5)
> The fix created a new bug... see my comment here
>
> https://github.com/dlang/dmd/commit/
> 3c53a0fd9ed1b40f8dbeb75b4dfa11f6df5b3062#commitcomment-19312704
Please file bug reports on bugzilla, not on github.