@@ -11634,10 +11634,14 @@ Compressor.prototype.compress = function(node) {
|
|||||||
});
|
});
|
||||||
self.right = rhs.right;
|
self.right = rhs.right;
|
||||||
if (compressor) {
|
if (compressor) {
|
||||||
self.left = self.left.transform(compressor);
|
var left = self.left.transform(compressor);
|
||||||
} else if (self.operator == rhs.left.operator) {
|
if (left !== self.left) {
|
||||||
swap_chain(self.left);
|
self = self.clone();
|
||||||
|
self.left = left;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
if (self.operator == rhs.left.operator) swap_chain(self.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
OPT(AST_Binary, function(self, compressor) {
|
OPT(AST_Binary, function(self, compressor) {
|
||||||
@@ -11825,7 +11829,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
// x && (y && z) ---> x && y && z
|
// x && (y && z) ---> x && y && z
|
||||||
// w || (x, y || z) ---> w || (x, y) || z
|
// w || (x, y || z) ---> w || (x, y) || z
|
||||||
var rhs = self.right.tail_node();
|
var rhs = self.right.tail_node();
|
||||||
if (rhs instanceof AST_Binary && self.operator == rhs.operator) swap_chain(self, compressor);
|
if (rhs instanceof AST_Binary && self.operator == rhs.operator) self = swap_chain(self, compressor);
|
||||||
}
|
}
|
||||||
if (compressor.option("strings") && self.operator == "+") {
|
if (compressor.option("strings") && self.operator == "+") {
|
||||||
// "foo" + 42 + "" ---> "foo" + 42
|
// "foo" + 42 + "" ---> "foo" + 42
|
||||||
@@ -11858,7 +11862,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
&& (self.left.is_string(compressor) && rhs.is_string(compressor)
|
&& (self.left.is_string(compressor) && rhs.is_string(compressor)
|
||||||
|| rhs.left.is_string(compressor)
|
|| rhs.left.is_string(compressor)
|
||||||
&& (self.left.is_constant() || !rhs.right.has_side_effects(compressor)))) {
|
&& (self.left.is_constant() || !rhs.right.has_side_effects(compressor)))) {
|
||||||
swap_chain(self, compressor);
|
self = swap_chain(self, compressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compressor.option("evaluate")) {
|
if (compressor.option("evaluate")) {
|
||||||
|
|||||||
@@ -3068,3 +3068,23 @@ issue_5712: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5722: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
keep_fnames: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = true;
|
||||||
|
a && function f() {
|
||||||
|
return 42;
|
||||||
|
}(a++) ? null + (console.log("PASS") && a++) : "";
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = true;
|
||||||
|
a && (void a++, console.log("PASS")) && a++;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user