enhance `unused` (#4098)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sat, 12 Sep 2020 17:05:43 +0000 (18:05 +0100)
committerGitHub <noreply@github.com>
Sat, 12 Sep 2020 17:05:43 +0000 (01:05 +0800)
lib/compress.js
test/compress/drop-unused.js

index 50a37a6..f34673d 100644 (file)
@@ -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
index 052a013..96273a8 100644 (file)
@@ -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",