Skip to content

Commit

Permalink
fix corner case in unused (#4850)
Browse files Browse the repository at this point in the history
fixes #4849
  • Loading branch information
alexlamsl committed Apr 7, 2021
1 parent a37ca55 commit ebe4e1a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -9393,6 +9393,7 @@ merge(Compressor.prototype, {
var seq = lift_sequence_in_expression(self, compressor);
if (seq !== self) return seq.optimize(compressor);
}
if (compressor.option("unused")) drop_unused_call_args(self, compressor);
if (compressor.option("unsafe")) {
var exp = self.expression;
if (is_undeclared_ref(exp)) {
Expand Down
4 changes: 2 additions & 2 deletions test/compress/exponentiation.js
Expand Up @@ -99,8 +99,8 @@ issue_4664: {
expect: {
(function f() {
new function(a) {
console.log(typeof f, 2 ** 30, typeof this);
}(0, A = 0);
console.log(typeof f, 1073741824, typeof this);
}(A = 0);
})();
}
expect_stdout: "function 1073741824 object"
Expand Down
23 changes: 23 additions & 0 deletions test/compress/spreads.js
Expand Up @@ -1045,3 +1045,26 @@ issue_4614: {
expect_stdout: true
node_version: ">=6"
}

issue_4849: {
options = {
reduce_vars: true,
unused: true,
}
input: {
while (function() {
while (!console);
}(new function(a) {
console.log(typeof { ...a });
}(function() {})));
}
expect: {
while (function() {
while (!console);
}(function(a) {
console.log(typeof { ...function() {} });
}()));
}
expect_stdout: "object"
node_version: ">=8"
}

0 comments on commit ebe4e1a

Please sign in to comment.