From d8e0e34354ea8c93a321210ba8a01d1a88a1dbc7 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 13 Feb 2018 07:10:37 +0800 Subject: [PATCH] collapse within unary expressions (#2910) --- lib/compress.js | 3 +++ test/compress/functions.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index ad691f7a..a161b457 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1260,6 +1260,8 @@ merge(Compressor.prototype, { } else if (expr instanceof AST_Unary) { if (expr.operator == "++" || expr.operator == "--") { candidates.push(hit_stack.slice()); + } else { + extract_candidates(expr.expression); } } else if (expr instanceof AST_VarDef) { if (expr.value) { @@ -1314,6 +1316,7 @@ merge(Compressor.prototype, { return find_stop(parent, level + 1, true); } if (parent instanceof AST_Switch) return node; + if (parent instanceof AST_Unary) return node; if (parent instanceof AST_VarDef) return node; return null; } diff --git a/test/compress/functions.js b/test/compress/functions.js index a964f104..2c034559 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -1343,7 +1343,7 @@ issue_2630_4: { var x = 3, a = 1, b = 2; (function() { (function() { - while (--x >= 0 && void (a++, b += a)); + while (--x >= 0 && void (b += ++a)); })(); })(); console.log(a); -- 2.34.1