Fix let scoping to work with while loops
This commit is contained in:
parent
5bad458b09
commit
680c6b166a
@ -265,11 +265,11 @@ LetScoping.prototype.checkFor = function () {
|
||||
traverse(this.block, function (node) {
|
||||
var replace;
|
||||
|
||||
if (t.isFunction(node) || t.isFor(node)) {
|
||||
if (t.isFunction(node) || t.isLoop(node) || t.isSwitchStatement(node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (forParent && node && !node.label) {
|
||||
if (node && !node.label) {
|
||||
if (t.isBreakStatement(node)) {
|
||||
has.hasBreak = true;
|
||||
replace = t.returnStatement(t.literal("break"));
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
"BreakStatement": ["Statement"],
|
||||
"ContinueStatement": ["Statement"],
|
||||
"DebuggerStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement", "Loop", "With"],
|
||||
"IfStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement"],
|
||||
"SwitchStatement": ["Statement"],
|
||||
"ThrowStatement": ["Statement"],
|
||||
"TryStatement": ["Statement"],
|
||||
"WhileStatement": ["Statement"],
|
||||
"WithStatement": ["Statement"],
|
||||
"WithStatement": ["Statement", "Loop", "With"],
|
||||
"EmptyStatement": ["Statement"],
|
||||
"LabeledStatement": ["Statement"],
|
||||
"VariableDeclaration": ["Statement", "Declaration"],
|
||||
@ -35,9 +35,9 @@
|
||||
"ClassDeclaration": ["Statement", "Declaration", "Class"],
|
||||
"ClassExpression": ["Class"],
|
||||
|
||||
"ForOfStatement": ["Statement", "For", "Scope"],
|
||||
"ForInStatement": ["Statement", "For", "Scope"],
|
||||
"ForStatement": ["Statement", "For", "Scope"],
|
||||
"ForOfStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
"ForInStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
"ForStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
|
||||
"ObjectPattern": ["Pattern"],
|
||||
"ArrayPattern": ["Pattern"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user