Skip to content

Commit

Permalink
fix corner case in dead_code (#5883)
Browse files Browse the repository at this point in the history
fixes #5882
  • Loading branch information
alexlamsl authored Jul 14, 2024
1 parent 8cfa37e commit b6b0658
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -13066,10 +13066,11 @@ Compressor.prototype.compress = function(node) {
|| !compressor.has_directive("use strict")
&& exp instanceof AST_Constant
&& !exp.may_throw_on_access(compressor)) {
return self.left instanceof AST_Dot ? self.right : make_sequence(self, [
var value = self.left instanceof AST_Dot ? self.right : make_sequence(self, [
self.left.property,
self.right
]).optimize(compressor);
self.right,
]);
return maintain_this_binding(compressor.parent(), self, value).optimize(compressor);
}
}
} else if (self.left instanceof AST_SymbolRef && can_drop_symbol(self.left, compressor)) {
Expand Down
46 changes: 46 additions & 0 deletions test/compress/dead-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -1730,3 +1730,49 @@ issue_5641: {
}
expect_stdout: "PASS"
}

issue_5882_1: {
options = {
dead_code: true,
pure_getters: "strict",
}
input: {
console.log(delete (42..p = NaN));
}
expect: {
console.log(delete (0, NaN));
}
expect_stdout: "true"
}

issue_5882_2: {
options = {
dead_code: true,
pure_getters: "strict",
sequences: true,
side_effects: true,
}
input: {
console.log(delete (42..p = NaN));
}
expect: {
console.log(delete (0, NaN));
}
expect_stdout: "true"
}

issue_5882_3: {
options = {
dead_code: true,
pure_getters: "strict",
sequences: true,
side_effects: true,
}
input: {
console.log(delete (42..p = Infinity));
}
expect: {
console.log(delete (1 / 0));
}
expect_stdout: "true"
}

0 comments on commit b6b0658

Please sign in to comment.