aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-02-13 07:10:37 +0800
committerGitHub <noreply@github.com>2018-02-13 07:10:37 +0800
commitd8e0e34354ea8c93a321210ba8a01d1a88a1dbc7 (patch)
tree0cc2ab9977bfb5226f0dc7c65e895bd918959af1
parent0c4f315c026e607d00dd74ad7417344a937bf6dd (diff)
downloadtracifyjs-d8e0e34354ea8c93a321210ba8a01d1a88a1dbc7.tar.gz
tracifyjs-d8e0e34354ea8c93a321210ba8a01d1a88a1dbc7.zip
collapse within unary expressions (#2910)
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/functions.js2
2 files changed, 4 insertions, 1 deletions
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);
f='/guix/commit/gnu/packages/guile.scm?id=f69cf40741f6ba4e79a5e8f6dae407d96f4433ec'>gnu: 'define-deprecated-guile3.0-package' actually exports <package> objects....Ludovic Courtès 2020-05-10gnu: guile-next: Mark as deprecated alias for "guile"....Ludovic Courtès 2020-05-10gnu: guile-git: Prevent guild build warnings....Efraim Flashner 2020-04-30gnu: guile-json: Update to 3.5.0....Marius Bakke 2020-04-18guix: self: Use guile with libgc-7....Christopher Baines 2020-04-11gnu: guile-json: Cross-build fix....Jan (janneke) Nieuwenhuizen 2020-04-11gnu: guile@3: Disable JIT on GNU/Hurd....Ludovic Courtès 2020-04-08Merge branch 'master' into core-updates...Marius Bakke 2020-04-06gnu: guile-for-guile-emacs: Update to 2.1.2-1.15ca784....Ricardo Wurmus 2020-03-29gnu: guile: Disable failing tests on the Hurd....Jan Nieuwenhuizen 2020-03-28gnu: Adjust 'package-for-guile-2.0' for the Guile 3 switch....Marius Bakke 2020-03-27gnu: guile: Update to 3.0.2....Marius Bakke 2020-03-27gnu: guile-next: Update to 3.0.2....Ludovic Courtès