switch block scoping for in/of var hoisting statements - fixes #2174

This commit is contained in:
Sebastian McKenzie 2015-08-06 17:36:42 +01:00
parent 68d750120a
commit aba44e38b7
3 changed files with 23 additions and 1 deletions

View File

@ -233,8 +233,8 @@ var hoistVarDeclarationsVisitor = {
}
} else if (this.isFor()) {
if (isVar(node.left, node)) {
node.left = node.left.declarations[0].id;
self.pushDeclar(node.left);
node.left = node.left.declarations[0].id;
}
} else if (isVar(node, parent)) {
return self.pushDeclar(node).map(t.expressionStatement);

View File

@ -0,0 +1,7 @@
if (true) {
function foo() {}
function bar() {
return foo;
}
for (var x in {}) {}
}

View File

@ -0,0 +1,15 @@
"use strict";
if (true) {
var x;
(function () {
var foo = function foo() {};
var bar = function bar() {
return foo;
};
for (x in {}) {}
})();
}