[Pkg-javascript-commits] [uglifyjs] 09/491: fix `reduce_vars` on boolean binary expressions (#1819)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:17 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 6d5f341999da7dfad708979151932fd9d8242ebd
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Mon Apr 17 17:24:29 2017 +0800
fix `reduce_vars` on boolean binary expressions (#1819)
Side effects of `&&` and `||` have not mattered until #1814, which takes assignment expressions into account.
---
lib/compress.js | 8 ++++++++
test/compress/reduce_vars.js | 23 +++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/lib/compress.js b/lib/compress.js
index 7324fe0..f49dd60 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -340,6 +340,14 @@ merge(Compressor.prototype, {
});
}
}
+ if (node instanceof AST_Binary
+ && (node.operator == "&&" || node.operator == "||")) {
+ node.left.walk(tw);
+ push();
+ node.right.walk(tw);
+ pop();
+ return true;
+ }
if (node instanceof AST_If) {
node.condition.walk(tw);
push();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 82b0021..94d37cb 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2217,3 +2217,26 @@ try_abort: {
}
expect_stdout: "1 undefined"
}
+
+boolean_binary_assign: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ !function() {
+ var a;
+ void 0 && (a = 1);
+ console.log(a);
+ }();
+ }
+ expect: {
+ !function() {
+ var a;
+ void 0;
+ console.log(a);
+ }();
+ }
+ expect_stdout: "undefined"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list