From: Alex Lam S.L Date: Thu, 17 Dec 2020 16:55:19 +0000 (+0000) Subject: fix corner case in `inline` (#4389) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=02fdcfde01cf41cae9449dbde4ceb74564bb35f3;p=UglifyJS.git fix corner case in `inline` (#4389) fixes #4388 --- diff --git a/lib/compress.js b/lib/compress.js index ffc19b25..2c50cb37 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -8026,8 +8026,14 @@ merge(Compressor.prototype, { })); if (found) return false; } - var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars) - && (exp !== fn || fn.parent_scope.resolve() === scope); + var safe_to_inject = exp !== fn || fn.parent_scope.resolve() === scope; + if (scope instanceof AST_Toplevel) { + if (compressor.toplevel.vars) { + defined["arguments"] = true; + } else { + safe_to_inject = false; + } + } var inline = compressor.option("inline"); var used = Object.create(defined); if (!can_inject_args(defined, used, inline >= 2 && safe_to_inject)) return false; diff --git a/test/compress/arrows.js b/test/compress/arrows.js index 02c4acde..eded9134 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -336,3 +336,18 @@ trim_body: { expect_stdout: "PASS undefined" node_version: ">=4" } + +issue_4388: { + options = { + inline: true, + toplevel: true, + } + input: { + (arguments => console.log(arguments && arguments))(); + } + expect: { + (arguments => console.log(arguments && arguments))(); + } + expect_stdout: "undefined" + node_version: ">=4" +}