May 04, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 --- Comment #10 from bearophile_hugs@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: ------- |
May 11, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 --- Comment #11 from yebblies <yebblies@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: ------- |
July 01, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #12 from yebblies <yebblies@gmail.com> 2013-07-01 15:33:39 EST --- This was fixed ages ago. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 01, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #13 from yebblies <yebblies@gmail.com> 2013-07-01 15:34:45 EST --- *** Issue 10506 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 01, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | --- Comment #14 from monarchdodra@gmail.com 2013-07-01 00:39:34 PDT --- Not fully fixed for @safe. The conditions to reproduce are a bit complicated actually. It requires attribute inference, mixin and default args (!) I'm not sure which it is that it producing the problem: -------- string bar(string op = "+") @property { return "a" ~ op ~ "b"; } void foo()() { int a, b; int c = mixin(bar); } @safe void main() { foo!()(); } -------- main.d(14): Error: safe function 'D main' cannot call system function 'main.foo!().foo' -------- Observations: 1) The problem is only with @safe, not pure. 2) Calling "min(bar("+"))" also makes the problem go away. Built with HEAD from 30-06-2013 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 01, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 --- Comment #15 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-01 08:01:17 PDT --- (In reply to comment #14) > Not fully fixed for @safe. The conditions to reproduce are a bit complicated actually. It requires attribute inference, mixin and default args (!) I'm not sure which it is that it producing the problem: https://github.com/D-Programming-Language/dmd/pull/2290 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 08, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 --- Comment #16 from github-bugzilla@puremagic.com 2013-07-07 21:09:32 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c2647ba31e7a60ccc354e67aad3a05ceaf7b755e Remain fix for issue 6169 Add ctfeResolveProperties() which avoids purity and safety check https://github.com/D-Programming-Language/dmd/commit/d895e4e8463de991c7b3ea723803374d6f9bf36a Merge pull request #2290 from 9rnsr/fix6169 Remain fix for issue 6169 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 14, 2013 [Issue 6169] [CTFE] pure functions cannot compute constants using functions not marked as pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6169 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation