fix for-in/of regression with let or const loop variable (#2840)

fixes #2835
This commit is contained in:
kzc
2018-01-22 16:45:02 -05:00
committed by Alex Lam S.L
parent bea9dbd812
commit e0461dc3c8
2 changed files with 179 additions and 4 deletions

View File

@@ -1759,7 +1759,7 @@ merge(Compressor.prototype, {
var stat = null;
for (var i = 0, len = block.body.length; i < len; i++) {
var line = block.body[i];
if (line instanceof AST_Definitions && declarations_only(line)) {
if (line instanceof AST_Var && declarations_only(line)) {
decls.push(line);
} else if (stat) {
return false;
@@ -1803,7 +1803,9 @@ merge(Compressor.prototype, {
}
}
} else if (stat instanceof AST_ForIn) {
stat.object = cons_seq(stat.object);
if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
stat.object = cons_seq(stat.object);
}
} else if (stat instanceof AST_If) {
stat.condition = cons_seq(stat.condition);
} else if (stat instanceof AST_Switch) {