Skip to content

Commit

Permalink
fix duplicate let scoping in functions - fixes #166
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmck committed Nov 14, 2014
1 parent c9d9a08 commit 7a261a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# 1.12.4

* Fix duplicate let scoping in functions.

# 1.12.13

* Support duplicate constants within different block scopes.
Expand Down
5 changes: 3 additions & 2 deletions lib/6to5/transformation/transformers/let-scoping.js
Expand Up @@ -74,7 +74,6 @@ function LetScoping(forParent, block, parent, file, scope) {

this.letReferences = {};
this.body = [];
this.info = this.getInfo();
}

/**
Expand All @@ -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();
Expand Down
@@ -0,0 +1,10 @@
function test () {
let value = "outer";

return (function () {
let value = "inner";
return value;
})();
}

assert(test(), "inner");

0 comments on commit 7a261a1

Please sign in to comment.