[Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 4 11:11:42 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6169
--- Comment #10 from bearophile_hugs at eml.cc 2013-05-04 11:11:40 PDT ---
(In reply to comment #1)
> pure nothrow int foo() {
> int x = 1;
> nothrow int bar(int y) { // nonpure
> x++;
> return x + y;
> }
>
> pure nothrow int spam() {
> enum z = bar(1); // calls a nonpure
> return z;
> }
> return spam() + spam();
> }
>
> enum r = foo();
> void main() {}
A reduction of that code:
int foo() {
int x = 0;
int bar() {
return x;
}
enum y = bar();
return 0;
}
enum r = foo();
void main() {}
It gives:
temp.d(4): Error: variable x cannot be read at compile time
temp.d(6): called from here: bar()
temp.d(9): called from here: foo()
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list