@@ -7226,30 +7226,36 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
var rhs = right.drop_side_effect_free(compressor, first_in_statement);
|
||||
if (!rhs) return left.drop_side_effect_free(compressor, first_in_statement);
|
||||
if (lazy_op[op] && !(rhs instanceof AST_Function)) {
|
||||
if (lazy_op[op] && rhs.has_side_effects(compressor)) {
|
||||
var node = this;
|
||||
if (op == "&&"
|
||||
&& rhs instanceof AST_PropAccess
|
||||
&& left.equivalent_to(rhs.expression)
|
||||
&& !left.has_side_effects(compressor)) {
|
||||
var prop = rhs instanceof AST_Sub && rhs.property.drop_side_effect_free(compressor);
|
||||
var prop = rhs instanceof AST_Sub
|
||||
&& rhs.property.drop_side_effect_free(compressor, first_in_statement);
|
||||
if (!prop) return left.drop_side_effect_free(compressor, first_in_statement);
|
||||
node = node.clone();
|
||||
node.right = prop;
|
||||
} else if (rhs !== right) {
|
||||
return node.drop_side_effect_free(compressor, first_in_statement);
|
||||
}
|
||||
if (rhs !== right) {
|
||||
node = node.clone();
|
||||
node.right = rhs.drop_side_effect_free(compressor);
|
||||
}
|
||||
if (op == "??") return node;
|
||||
return (first_in_statement ? best_of_statement : best_of_expression)(node, make_node(AST_Binary, this, {
|
||||
var negated = make_node(AST_Binary, this, {
|
||||
operator: op == "&&" ? "||" : "&&",
|
||||
left: left.negate(compressor, first_in_statement),
|
||||
right: node.right,
|
||||
}));
|
||||
});
|
||||
return first_in_statement ? best_of_statement(node, negated) : best_of_expression(node, negated);
|
||||
} else {
|
||||
var lhs = left.drop_side_effect_free(compressor, first_in_statement);
|
||||
if (!lhs) return rhs;
|
||||
return make_sequence(this, [ lhs, rhs.drop_side_effect_free(compressor) ]);
|
||||
rhs = rhs.drop_side_effect_free(compressor);
|
||||
if (!rhs) return lhs;
|
||||
return make_sequence(this, [ lhs, rhs ]);
|
||||
}
|
||||
});
|
||||
def(AST_Call, function(compressor, first_in_statement) {
|
||||
|
||||
@@ -2919,3 +2919,28 @@ issue_4568: {
|
||||
}
|
||||
expect_stdout: "undefined 1"
|
||||
}
|
||||
|
||||
issue_4729: {
|
||||
options = {
|
||||
ie8: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
try {
|
||||
f;
|
||||
} catch(e) {
|
||||
var a = a && a[function f() {}];
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
try {
|
||||
f;
|
||||
} catch(e) {
|
||||
(function f() {});
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
@@ -558,3 +558,33 @@ drop_side_effect_free_call: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_4730_1: {
|
||||
options = {
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
var a;
|
||||
console.log("PASS") + (a && a[a.p]);
|
||||
}
|
||||
expect: {
|
||||
var a;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_4730_2: {
|
||||
options = {
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
var a;
|
||||
!console.log("PASS") || a && a[a.p];
|
||||
}
|
||||
expect: {
|
||||
var a;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user