Skip to content

Commit

Permalink
fix corner case in inline (#4322)
Browse files Browse the repository at this point in the history
fixes #4321
  • Loading branch information
alexlamsl authored Nov 28, 2020
1 parent af1cca2 commit 8791f25
Show file tree
Hide file tree
Showing 2 changed files with 35 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 @@ -4609,12 +4609,13 @@ merge(Compressor.prototype, {
var len = fn.argnames.length;
if (len > 0 && compressor.option("inline") < 2) break;
if (len > self.argnames.length) break;
if (!all(self.argnames, function(argname) {
return argname instanceof AST_SymbolFunarg;
})) break;
for (var j = 0; j < len; j++) {
var arg = call.args[j];
if (!(arg instanceof AST_SymbolRef)) break;
var argname = self.argnames[j];
if (!(argname instanceof AST_SymbolFunarg)) break;
if (arg.definition() !== argname.definition()) break;
if (arg.definition() !== self.argnames[j].definition()) break;
}
if (j < len) break;
for (; j < call.args.length; j++) {
Expand Down
31 changes: 31 additions & 0 deletions test/compress/destructured.js
Original file line number Diff line number Diff line change
Expand Up @@ -1710,3 +1710,34 @@ issue_4319: {
expect_stdout: "undefined"
node_version: ">=6"
}

issue_4321: {
options = {
inline: true,
keep_fargs: "strict",
}
input: {
try {
console.log(function({}) {
return function() {
while (!console);
}();
}());
} catch (e) {
console.log("PASS");
}
}
expect: {
try {
console.log(function({}) {
return function() {
while (!console);
}();
}());
} catch (e) {
console.log("PASS");
}
}
expect_stdout: "PASS"
node_version: ">=6"
}

0 comments on commit 8791f25

Please sign in to comment.