diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-12-02 12:28:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 12:28:17 +0800 |
commit | bef856addb7ac977b516a9bcd155c897a7d0dd99 (patch) | |
tree | d8e5a573e40c7194ec4fa9bee374a26dcd9ae99e | |
parent | 9a6faf365bdd481be733bafb8c580bc76f4b353e (diff) | |
download | tracifyjs-bef856addb7ac977b516a9bcd155c897a7d0dd99.tar.gz tracifyjs-bef856addb7ac977b516a9bcd155c897a7d0dd99.zip |
fix corner case in `keep_fargs` (#3620)
fixes #3619
-rw-r--r-- | lib/compress.js | 3 | ||||
-rw-r--r-- | test/compress/keep_fargs.js | 30 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index 284b79ad..2c60a9b6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5173,8 +5173,7 @@ merge(Compressor.prototype, { && !fn.uses_arguments && !fn.pinned()) { var pos = 0, last = 0; - var drop_fargs = exp === fn && compressor.drop_fargs(fn, self) - && (!fn.name || !fn.name.definition().recursive_refs); + var drop_fargs = exp === fn && !fn.name && compressor.drop_fargs(fn, self); var side_effects = []; for (var i = 0; i < self.args.length; i++) { var trim = i >= fn.argnames.length; diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js index 29308ff3..a17a8f3f 100644 --- a/test/compress/keep_fargs.js +++ b/test/compress/keep_fargs.js @@ -1425,3 +1425,33 @@ recursive_iife_3: { } expect_stdout: "PASS" } + +issue_3619: { + options = { + keep_fargs: false, + unused: true, + } + input: { + var a = 1, b = "FAIL"; + (function f(c, d) { + function g() { + d && (b = "PASS", 0 <= --a && g()); + 0 <= --a && f(0, "function"); + } + g(); + })(); + console.log(b); + } + expect: { + var a = 1, b = "FAIL"; + (function f(c, d) { + function g() { + d && (b = "PASS", 0 <= --a && g()); + 0 <= --a && f(0, "function"); + } + g(); + })(); + console.log(b); + } + expect_stdout: "PASS" +} |