[parenscript-devel] Bug: inconsistent gensym suffixes on what ought to be the same loop control variable
![](https://secure.gravatar.com/avatar/f280fbf7764035c257f907cf2223eac0.jpg?s=120&d=mm&r=g)
I just ran into a strange bug where the gensym'd suffixes on loop control variables change to the wrong thing. The bug appears to be triggered by a (RETURN) form inside a loop that has more than one FOR clause. For each extra clause, the suffixes increase by one. I haven't tried to track down the cause of the bug, but I did just push a failing test (LOOP-PARALLEL-CLAUSES-WITH-RETURN) to illustrate it. (defun-js foo () (loop :for i :from 0 :below 10 :for x = (* i 10) :when (> i 5) :do (return x) :collect i)) => (note added comments below): function foo() { return (function () { var collect3170 = []; var loopResultVarSet3171 = null; var loopResultVar3172 = null; for (var i = 0; i < 10; i += 1) { var x3171 = i * 10; if (i > 5) { loopResultVarSet3172 = true; // <---- suffix should be 3171, not 3172 loopResultVar3173 = x3171; // <---- suffix should be 3172, not 3173 break; }; collect3170.push(i); }; if (loopResultVarSet3171) { return loopResultVar3172; }; return collect3170; })(); }; Daniel
![](https://secure.gravatar.com/avatar/6a2a0564e2c584c8e9fa1ec369bd23e0.jpg?s=120&d=mm&r=g)
Thanks for that bug report Dan. I'm not sure why that didn't come up earlier. I fixed the problem by getting rid of the whole loopResultVar thing - with the new RETURN transformations values can be returned directly, and that simplifies the generated code (and the Parenscript compiler) a lot. The fix is now pushed. Vladimir On Fri, Sep 14, 2012 at 1:32 AM, Daniel Gackle <danielgackle@gmail.com> wrote:
I just ran into a strange bug where the gensym'd suffixes on loop control variables change to the wrong thing. The bug appears to be triggered by a (RETURN) form inside a loop that has more than one FOR clause. For each extra clause, the suffixes increase by one. I haven't tried to track down the cause of the bug, but I did just push a failing test (LOOP-PARALLEL-CLAUSES-WITH-RETURN) to illustrate it.
(defun-js foo () (loop :for i :from 0 :below 10 :for x = (* i 10) :when (> i 5) :do (return x) :collect i))
=> (note added comments below):
function foo() { return (function () { var collect3170 = []; var loopResultVarSet3171 = null; var loopResultVar3172 = null; for (var i = 0; i < 10; i += 1) { var x3171 = i * 10; if (i > 5) { loopResultVarSet3172 = true; // <---- suffix should be 3171, not 3172 loopResultVar3173 = x3171; // <---- suffix should be 3172, not 3173 break; }; collect3170.push(i); }; if (loopResultVarSet3171) { return loopResultVar3172; }; return collect3170; })(); };
Daniel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
![](https://secure.gravatar.com/avatar/f280fbf7764035c257f907cf2223eac0.jpg?s=120&d=mm&r=g)
Yes, that fixed it. Thanks! On Sat, Sep 15, 2012 at 3:22 PM, Vladimir Sedach <vsedach@gmail.com> wrote:
Thanks for that bug report Dan. I'm not sure why that didn't come up earlier.
I fixed the problem by getting rid of the whole loopResultVar thing - with the new RETURN transformations values can be returned directly, and that simplifies the generated code (and the Parenscript compiler) a lot.
The fix is now pushed.
Vladimir
On Fri, Sep 14, 2012 at 1:32 AM, Daniel Gackle <danielgackle@gmail.com> wrote:
I just ran into a strange bug where the gensym'd suffixes on loop control variables change to the wrong thing. The bug appears to be triggered by a (RETURN) form inside a loop that has more than one FOR clause. For each extra clause, the suffixes increase by one. I haven't tried to track down the cause of the bug, but I did just push a failing test (LOOP-PARALLEL-CLAUSES-WITH-RETURN) to illustrate it.
(defun-js foo () (loop :for i :from 0 :below 10 :for x = (* i 10) :when (> i 5) :do (return x) :collect i))
=> (note added comments below):
function foo() { return (function () { var collect3170 = []; var loopResultVarSet3171 = null; var loopResultVar3172 = null; for (var i = 0; i < 10; i += 1) { var x3171 = i * 10; if (i > 5) { loopResultVarSet3172 = true; // <---- suffix should be 3171, not 3172 loopResultVar3173 = x3171; // <---- suffix should be 3172, not 3173 break; }; collect3170.push(i); }; if (loopResultVarSet3171) { return loopResultVar3172; }; return collect3170; })(); };
Daniel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
participants (2)
-
Daniel Gackle
-
Vladimir Sedach