collapse within unary expressions (#2910)

This commit is contained in:
Alex Lam S.L
2018-02-13 07:10:37 +08:00
committed by GitHub
parent 0c4f315c02
commit d8e0e34354
2 changed files with 4 additions and 1 deletions

View File

@@ -1260,6 +1260,8 @@ merge(Compressor.prototype, {
} else if (expr instanceof AST_Unary) { } else if (expr instanceof AST_Unary) {
if (expr.operator == "++" || expr.operator == "--") { if (expr.operator == "++" || expr.operator == "--") {
candidates.push(hit_stack.slice()); candidates.push(hit_stack.slice());
} else {
extract_candidates(expr.expression);
} }
} else if (expr instanceof AST_VarDef) { } else if (expr instanceof AST_VarDef) {
if (expr.value) { if (expr.value) {
@@ -1314,6 +1316,7 @@ merge(Compressor.prototype, {
return find_stop(parent, level + 1, true); return find_stop(parent, level + 1, true);
} }
if (parent instanceof AST_Switch) return node; if (parent instanceof AST_Switch) return node;
if (parent instanceof AST_Unary) return node;
if (parent instanceof AST_VarDef) return node; if (parent instanceof AST_VarDef) return node;
return null; return null;
} }

View File

@@ -1343,7 +1343,7 @@ issue_2630_4: {
var x = 3, a = 1, b = 2; var x = 3, a = 1, b = 2;
(function() { (function() {
(function() { (function() {
while (--x >= 0 && void (a++, b += a)); while (--x >= 0 && void (b += ++a));
})(); })();
})(); })();
console.log(a); console.log(a);