PS seems to think that the variable named BLOCK is being captured by
the irrelevant lambda and inserts a WITH binding.
PS> (ps (loop :for i :from 0 :below 5 :do
(let ((block (elt blocks i)))
(foo block)
(lambda () nil))))
"for (var i = 0; i < 5; i += 1) {
with ({ block : null }) {
var block = blocks[i];
foo(block);
function () {
return null;
};
};
};"
This doesn't happen if you take out the lambda:
PS> (ps (loop :for i :from 0 :below 5 :do
(let ((block (elt blocks i)))
(foo block))))
"for (var i = 0; i < 5; i += 1) {
var block = blocks[i];
foo(block);
};"
... or even if you rename BLOCK to B:
PS> (ps (loop :for i :from 0 :below 5 :do
(let ((b (elt blocks i)))
(foo b)
(lambda () nil))))
"for (var i = 0; i < 5; i += 1) {
var b = blocks[i];
foo(b);
function () {
return null;
};
};"
I thought this might be because PS had compiled a different form where
BLOCK was indeed captured by closure in a loop and was remembering
this inappropriately. But that doesn't seem right because the problem
is reproducible on a fresh restart of PS.
Daniel