Skip to content

Commit

Permalink
fix corner case in unused (#3674)
Browse files Browse the repository at this point in the history
fixes #3673
  • Loading branch information
alexlamsl committed Jan 7, 2020
1 parent 4d6771b commit f5ceff6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -4196,7 +4196,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_Assign) {
if (node.write_only === "p" && node.right.may_throw_on_access(compressor)) return;
var right = get_rhs(node);
if (init && node.write_only && node_def.scope === self && !right.has_side_effects(compressor)) {
if (init && node.write_only === true && node_def.scope === self && !right.has_side_effects(compressor)) {
initializations.add(node_def.id, right);
} else {
right.walk(tw);
Expand Down
20 changes: 20 additions & 0 deletions test/compress/drop-unused.js
Expand Up @@ -2355,3 +2355,23 @@ issue_3664: {
}
expect_stdout: "PASS"
}

issue_3673: {
options = {
pure_getters: "strict",
side_effects: true,
toplevel: true,
unused: true,
}
input: {
var a;
(a = [ a ]).p = 42;
console.log("PASS");
}
expect: {
var a;
(a = [ a ]).p = 42;
console.log("PASS");
}
expect_stdout: "PASS"
}

0 comments on commit f5ceff6

Please sign in to comment.