From af1cca25bf3c29aa925bbe2a164786ebcf7dd476 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 26 Nov 2020 17:31:06 +0000 Subject: [PATCH] fix corner case in `inline` (#4320) fixes #4319 --- lib/compress.js | 4 +++- test/compress/destructured.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 0e585e17..1d729096 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4612,7 +4612,9 @@ merge(Compressor.prototype, { for (var j = 0; j < len; j++) { var arg = call.args[j]; if (!(arg instanceof AST_SymbolRef)) break; - if (arg.definition() !== self.argnames[j].definition()) break; + var argname = self.argnames[j]; + if (!(argname instanceof AST_SymbolFunarg)) break; + if (arg.definition() !== argname.definition()) break; } if (j < len) break; for (; j < call.args.length; j++) { diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 6eea10d2..afc9152b 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -1684,3 +1684,29 @@ issue_4315: { expect_stdout: "PASS" node_version: ">=6" } + +issue_4319: { + options = { + inline: true, + reduce_vars: true, + toplevel: true, + } + input: { + function f(a) { + while (!a); + } + console.log(function({}) { + return f(console); + }(0)); + } + expect: { + function f(a) { + while (!a); + } + console.log(function({}) { + return f(console); + }(0)); + } + expect_stdout: "undefined" + node_version: ">=6" +} -- 2.34.1