fix scope tracking for constants in loop heads - fixes #1229

This commit is contained in:
Sebastian McKenzie 2015-04-11 16:39:18 -07:00
parent 1360c93e4b
commit 5326e0543d
3 changed files with 7 additions and 1 deletions

View File

@ -449,7 +449,7 @@ export default class Scope {
if (path.isLoop()) {
for (let i = 0; i < t.FOR_INIT_KEYS.length; i++) {
var node = path.get(t.FOR_INIT_KEYS[i]);
if (node.isBlockScoped()) this.registerBinding("let", node);
if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
}
}

View File

@ -0,0 +1,3 @@
for (const i = 0; i < 3; i = i + 1) {
console.log(i);
}

View File

@ -0,0 +1,3 @@
{
"throws": "Duplicate declaration \"i\""
}