From d33a3a3253e2370f6874b2e5b01e94d78406162d Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 12 Sep 2020 18:05:43 +0100 Subject: [PATCH] enhance `unused` (#4098) --- lib/compress.js | 1 + test/compress/drop-unused.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 50a37a68..f34673d6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4400,6 +4400,7 @@ merge(Compressor.prototype, { } return scan_ref_scoped(node, descend, true); }); + tw.directives = Object.create(compressor.directives); self.walk(tw); // pass 2: for every used symbol we need to walk its // initialization code to figure out if it uses other diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 052a013b..96273a8d 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -1997,7 +1997,7 @@ issue_3146_4: { expect_stdout: "PASS" } -issue_3192: { +issue_3192_1: { options = { unused: true, } @@ -2025,6 +2025,26 @@ issue_3192: { ] } +issue_3192_2: { + options = { + keep_fargs: "strict", + unused: true, + } + input: { + "use strict"; + (function(a) { + console.log(a = "foo", arguments[0]); + })("bar"); + } + expect: { + "use strict"; + (function() { + console.log("foo", arguments[0]); + })("bar"); + } + expect_stdout: "foo bar" +} + issue_3233: { options = { pure_getters: "strict", -- 2.34.1