Comment #0 by iamthewilsonator — 2019-06-14T10:46:17Z
From the source code of DMD no less!
void f() {
int fx;
pure void g() {
int gx;
/+pure+/ void h() {
int hx;
/+pure+/ void i() { fx = 0; }
}
}
}
should give
Error: pure nested function 'g' cannot access mutable data 'fx'
if the commented out `purees are removed it should give
Error: pure nested function 'i' cannot access mutable data 'fx'
three times.
Comment #1 by iamthewilsonator — 2019-06-14T11:28:43Z
*** Issue 19964 has been marked as a duplicate of this issue. ***
Comment #2 by bugzilla — 2019-12-18T10:44:28Z
I'm not sure what the problem is?
Comment #3 by razvan.nitu1305 — 2020-02-13T11:01:26Z
The problem is that function g is pure, but it contains function i that accesses the variable fx which is outside of its scope, thus violating purity. This code should issue an error, but it doesn't.
Comment #4 by robert.schadek — 2024-12-13T19:03:58Z