@@ -7415,9 +7415,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (left.has_side_effects(compressor)) return this;
|
if (left.has_side_effects(compressor)) return this;
|
||||||
var right = this.right;
|
var right = this.right;
|
||||||
if (lazy_op[this.operator.slice(0, -1)]) {
|
if (!lazy_op[this.operator.slice(0, -1)]) {
|
||||||
this.write_only = !right.has_side_effects(compressor);
|
|
||||||
} else {
|
|
||||||
this.write_only = true;
|
this.write_only = true;
|
||||||
if (root_expr(left).is_constant_expression(compressor.find_parent(AST_Scope))) {
|
if (root_expr(left).is_constant_expression(compressor.find_parent(AST_Scope))) {
|
||||||
return right.drop_side_effect_free(compressor);
|
return right.drop_side_effect_free(compressor);
|
||||||
|
|||||||
@@ -701,3 +701,48 @@ issue_4876: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=15"
|
node_version: ">=15"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4924_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
console.log("PASS");
|
||||||
|
a = function() {};
|
||||||
|
b = function() {}(b ||= a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var b;
|
||||||
|
console.log("PASS");
|
||||||
|
b = void (b ||= function() {});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4924_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
dead_code: true,
|
||||||
|
passes: 2,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
console.log("PASS");
|
||||||
|
a = function() {};
|
||||||
|
b = function() {}(b ||= a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user