fix duplicate let scoping in functions - fixes #166

This commit is contained in:
Sebastian McKenzie 2014-11-15 09:47:48 +11:00
parent c9d9a085f1
commit 7a261a1db1
3 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,7 @@
# 1.12.4
* Fix duplicate let scoping in functions.
# 1.12.13
* Support duplicate constants within different block scopes.

View File

@ -74,7 +74,6 @@ function LetScoping(forParent, block, parent, file, scope) {
this.letReferences = {};
this.body = [];
this.info = this.getInfo();
}
/**
@ -87,8 +86,10 @@ LetScoping.prototype.run = function () {
if (block._letDone) return;
block._letDone = true;
this.info = this.getInfo();
// this is a block within a `Function` so we can safely leave it be
if (t.isFunction(this.parent)) return;
if (t.isFunction(this.parent)) return this.noClosure();
// this block has no let references so let's clean up
if (!this.info.keys.length) return this.noClosure();

View File

@ -0,0 +1,10 @@
function test () {
let value = "outer";
return (function () {
let value = "inner";
return value;
})();
}
assert(test(), "inner");