[Pkg-javascript-commits] [uglifyjs] 10/11: Don't attempt to negate non-boolean AST_Binary
Jonas Smedegaard
dr at jones.dk
Wed Aug 26 09:34:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v2.4.24
in repository uglifyjs.
commit 905b6011784ca60d41919ac1a499962b7c1d4b02
Author: Mihai Bazon <mihai.bazon at gmail.com>
Date: Wed Jul 22 16:53:25 2015 +0300
Don't attempt to negate non-boolean AST_Binary
Fix #751
---
lib/compress.js | 2 +-
test/compress/issue-751.js | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 54873f0..4c4cf97 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2183,7 +2183,7 @@ merge(Compressor.prototype, {
}
break;
}
- if (compressor.option("comparisons")) {
+ if (compressor.option("comparisons") && self.is_boolean()) {
if (!(compressor.parent() instanceof AST_Binary)
|| compressor.parent() instanceof AST_Assign) {
var negated = make_node(AST_UnaryPrefix, self, {
diff --git a/test/compress/issue-751.js b/test/compress/issue-751.js
new file mode 100644
index 0000000..829b7ca
--- /dev/null
+++ b/test/compress/issue-751.js
@@ -0,0 +1,29 @@
+negate_booleans_1: {
+ options = {
+ comparisons: true
+ };
+ input: {
+ var a = !a || !b || !c || !d || !e || !f;
+ }
+ expect: {
+ var a = !(a && b && c && d && e && f);
+ }
+}
+
+negate_booleans_2: {
+ options = {
+ comparisons: true
+ };
+ input: {
+ var match = !x && // should not touch this one
+ (!z || c) &&
+ (!k || d) &&
+ the_stuff();
+ }
+ expect: {
+ var match = !x &&
+ (!z || c) &&
+ (!k || d) &&
+ the_stuff();
+ }
+}
--
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