[Issue 13729] [REG2.067a] One not detected case of not purity
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Feb 28 02:54:09 PST 2015
https://issues.dlang.org/show_bug.cgi?id=13729
--- Comment #3 from bearophile_hugs at eml.cc ---
Now this code:
int x;
void main() pure {
static void foo() {
x++;
}
foo();
}
Gives:
test.d(4,9): Error: pure function 'D main' cannot access mutable static data
'x'
I think a more precise error message should say that the pure function main()
can't call the impure static function foo(), and foo() can't be pure because it
writes static data.
This program shows that foo() doesn't need to be annotated with "pure" for the
code to compile:
int x;
void main() pure {
static void foo() {
}
foo();
}
--
More information about the Digitalmars-d-bugs
mailing list