fix corner case in `ie8` (#3890)
authorAlex Lam S.L <alexlamsl@gmail.com>
Tue, 12 May 2020 11:28:29 +0000 (12:28 +0100)
committerGitHub <noreply@github.com>
Tue, 12 May 2020 11:28:29 +0000 (19:28 +0800)
fixes #3889

lib/compress.js
test/compress/ie8.js

index e4f7589..c34c763 100644 (file)
@@ -399,6 +399,10 @@ merge(Compressor.prototype, {
                     }
                 });
             };
+            if (compressor.option("ie8")) scope.variables.each(function(def) {
+                var d = def.orig[0].definition();
+                if (d !== def) d.fixed = false;
+            });
         }
 
         function mark_defun(tw, def) {
index 53f78f1..68ccab1 100644 (file)
@@ -2460,3 +2460,32 @@ issue_3825: {
     }
     expect_stdout: "undefined"
 }
+
+issue_3889: {
+    options = {
+        evaluate: true,
+        ie8: true,
+        reduce_vars: true,
+    }
+    input: {
+        function f(a) {
+            a = 0;
+            (function a() {
+                var a;
+                console.log(a);
+            })();
+        }
+        f();
+    }
+    expect: {
+        function f(a) {
+            a = 0;
+            (function a() {
+                var a;
+                console.log(a);
+            })();
+        }
+        f();
+    }
+    expect_stdout: "undefined"
+}