[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 11 03:51:47 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=6169



--- Comment #11 from yebblies <yebblies at gmail.com> 2013-05-11 20:51:44 EST ---
(In reply to comment #10)
> 
> 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()

That appears to be correct.  While both 'foo' and 'bar' are running at compile
time, they are in different compile time evaluation contexts.  The evaluation
of 'y' _must_ be independent of the running of '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