collapse within unary expressions (#2910)
authorAlex Lam S.L <alexlamsl@gmail.com>
Mon, 12 Feb 2018 23:10:37 +0000 (07:10 +0800)
committerGitHub <noreply@github.com>
Mon, 12 Feb 2018 23:10:37 +0000 (07:10 +0800)
lib/compress.js
test/compress/functions.js

index ad691f7..a161b45 100644 (file)
@@ -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;
             }
index a964f10..2c03455 100644 (file)
@@ -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);