satyr/coco — Issue #108: Variable name reuse with loops and let
Author: jdknezek
Created: 2012-01-16 22:15:39+00:00
State: open

I see `let` has some edge cases when used with a loop variable:

$ coco -bce 'let a = a + 1 then'
(function(a){}.call(this, a + 1));

$ coco -bcs
for a in b
let c = c + 1 then

var a;
for (a in b) {
(_fn.call(this, c + 1, a));
}
function _fn(c, a){}

Notice that coco is being nice and capturing `a` for me. However, this means I can't define my own new `a`:

$ coco -bcs
for a in b
let a = a + 1 then

SyntaxError: duplicate parameter "a" on line undefined

It would be nice if coco would let me override the automatic capture:

$ coco -bcs
for a in b
let a = a + 1 then

var a;
for (a in b) {
(_fn.call(this, a + 1));
}
function _fn(a){}