Skip to content

Commit

Permalink
fix corner case in unused (#5066)
Browse files Browse the repository at this point in the history
fixes #5065
  • Loading branch information
alexlamsl committed Jul 10, 2021
1 parent f67dd31 commit aae1fcd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -7036,7 +7036,10 @@ merge(Compressor.prototype, {
if (compressor.option("default_values") && value && value.is_defined(compressor)) {
node = node.name;
} else {
var save_drop = drop;
drop = false;
var trimmed = trim_default(trimmer, node);
drop = save_drop;
if (!trimmed && drop && value) value = value.drop_side_effect_free(compressor);
return trimmed;
}
Expand Down
16 changes: 16 additions & 0 deletions test/compress/default-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -1874,3 +1874,19 @@ issue_5057_3: {
expect_stdout: "PASS"
node_version: ">=6"
}

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

0 comments on commit aae1fcd

Please sign in to comment.