digitalmars.D.bugs - [Issue 10506] New: Purity should not be checked in a mixin statement
- d-bugmail puremagic.com (28/31) Jun 29 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (25/25) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (10/12) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (15/15) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (21/26) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (36/63) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (9/30) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (7/8) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (14/14) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (11/11) Jul 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
- d-bugmail puremagic.com (10/10) Jul 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10506
http://d.puremagic.com/issues/show_bug.cgi?id=10506 Summary: Purity should not be checked in a mixin statement Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 12:59:23 PDT --- ----- import std.string; void test() pure { mixin(["foo", "bar"].join()); } void main() {} -----test.d(5): Error: pure function 'test.test' cannot call impure function 'std.array.join!(string[]).join' test.d(5): Error: found 'EOF' when expecting ';' following statement test.d(5): Error: undefined identifier foobarI think the above should be allowed. I can't think of a case where the code which *produces* the string to be mixed in can somehow affect the purity of the function the mixin statement is in. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 29 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Component|DMD |Phobos Resolution| |FIXED Currently (from 2.063) compiler disables purity check in CTFE context. void foobar() pure {} string gen() // impure { return "foobar;"; } void test() pure { mixin(gen()); // succeed to compile } That was the std.array.join issue. It uses std.array.Appender, but Appender had impure operation until very recent days. https://github.com/D-Programming-Language/phobos/commit/4da1639c98cb73d07858b17c2d225063889e4700#L0L2287 (static member function "Appender.newCapacity" was impure) Right now Appender operation is potentially pure, and in the OP case has been also changed to pure. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 05:25:04 PDT ---That was the std.array.join issue. It uses std.array.Appender, but Appender had impure operation until very recent days.Here's the thing though, aren't all functions when CTFE evaluated pure? You can't save any state or read global state while in CTFE, so I'm thinking that during a chain of CTFE calls (e.g. join -> appender -> newCapacity), it isn't necessary to check for purity? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com Component|Phobos |DMD Resolution|FIXED |DUPLICATE This is issue 6169, which was fixed a while ago. I don't know what compiler version you were using but I double-checked the source and it calls ctfeSemantic like it should. *** This issue has been marked as a duplicate of issue 6169 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 05:29:06 PDT ---This is issue 6169, which was fixed a while ago. I don't know what compiler version you were using but I double-checked the source and it calls ctfeSemantic like it should. *** This issue has been marked as a duplicate of issue 6169 ***Let's try this: ----- import std.string; void test() pure { mixin(["int ", "x;"].join()); } void main() {} ----- 2.061: ok 2.062: Error: pure function 'test' cannot call impure function 'join' 2.063: Error: pure function 'test' cannot call impure function 'join' 2.064: ok (but I think this is because join has become pure?) Note that the test-case in Issue 6169 works in all of these compilers, but not the sample I gave. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra gmail.comI have reopened 6169 with this usecase: -------- 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. -------- Not sure if this is strictly 6169 or if I should have posted here and un-resolved as duplicate. But in any case, this is (I think) a simpler use case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------This is issue 6169, which was fixed a while ago. I don't know what compiler version you were using but I double-checked the source and it calls ctfeSemantic like it should. *** This issue has been marked as a duplicate of issue 6169 ***Let's try this: ----- import std.string; void test() pure { mixin(["int ", "x;"].join()); } void main() {} ----- 2.061: ok 2.062: Error: pure function 'test' cannot call impure function 'join' 2.063: Error: pure function 'test' cannot call impure function 'join' 2.064: ok (but I think this is because join has become pure?) Note that the test-case in Issue 6169 works in all of these compilers, but not the sample I gave.
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506Let's try this: ----- import std.string; void test() pure { mixin(["int ", "x;"].join()); } void main() {} ----- 2.061: ok 2.062: Error: pure function 'test' cannot call impure function 'join' 2.063: Error: pure function 'test' cannot call impure function 'join' 2.064: ok (but I think this is because join has become pure?) Note that the test-case in Issue 6169 works in all of these compilers, but not the sample I gave.Ah, I think I know what's going on. Does it possibly work in 2.063 when not using ufcs? I think it's only getting the direct calls to semantic, but some others are being missed (eg resolveProperties) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 06:10:13 PDT ---Does it possibly work in 2.063 when not using ufcs?No, I get the same results. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Status|RESOLVED |REOPENED Resolution|DUPLICATE | https://github.com/D-Programming-Language/dmd/pull/2289 Essentially this issue has been caused by the incomplete fix for bug 6169. But the actual issue is very small, so I'd like to keep this independent from that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/075f1ec31be42d13be4ca44fb861dd71216701c3 fix Issue 10506 - Purity should not be checked in a mixin statement https://github.com/D-Programming-Language/dmd/commit/d16ce295dddda97d00cd3d2aabeb862e85437e02 Issue 10506 - Purity should not be checked in a mixin statement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10506 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 05 2013