diff --git a/lib/6to5/transformation/transformers/es6-let-scoping.js b/lib/6to5/transformation/transformers/es6-let-scoping.js index f6d9010154..353dc578d1 100644 --- a/lib/6to5/transformation/transformers/es6-let-scoping.js +++ b/lib/6to5/transformation/transformers/es6-let-scoping.js @@ -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")); diff --git a/lib/6to5/types/alias-keys.json b/lib/6to5/types/alias-keys.json index b8920e3cd3..0dc76ee2b6 100644 --- a/lib/6to5/types/alias-keys.json +++ b/lib/6to5/types/alias-keys.json @@ -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"],