From: Alex Lam S.L Date: Sat, 28 Nov 2020 19:48:42 +0000 (+0000) Subject: fix corner case in `inline` (#4322) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=8791f258e3996adb882fc62329f970270366b216;p=UglifyJS.git fix corner case in `inline` (#4322) fixes #4321 --- diff --git a/lib/compress.js b/lib/compress.js index 1d729096..7759ff11 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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++) { diff --git a/test/compress/destructured.js b/test/compress/destructured.js index afc9152b..d751e253 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -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" +}