fix `ie8` mangling of top-level `AST_SymbolCatch` (#2263)
authorAlex Lam S.L <alexlamsl@gmail.com>
Mon, 31 Jul 2017 18:38:32 +0000 (02:38 +0800)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2017 18:38:32 +0000 (02:38 +0800)
fixes #2254

lib/scope.js
test/compress/screw-ie8.js

index df7b207..8e766a5 100644 (file)
@@ -235,6 +235,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
                     ref.reference(options);
                 });
                 node.thedef = def;
+                node.reference(options);
                 return true;
             }
         }));
index 5d6f1e2..66559b0 100644 (file)
@@ -325,3 +325,69 @@ issue_2120_2: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2254_1: {
+    mangle = {
+        ie8: false,
+    }
+    input: {
+        "eeeeee";
+        try {
+            console.log(f("PASS"));
+        } catch (e) {}
+        function f(s) {
+            try {
+                throw "FAIL";
+            } catch (e) {
+                return s;
+            }
+        }
+    }
+    expect: {
+        "eeeeee";
+        try {
+            console.log(f("PASS"));
+        } catch (e) {}
+        function f(e) {
+            try {
+                throw "FAIL";
+            } catch (t) {
+                return e;
+            }
+        }
+    }
+    expect_stdout: "PASS"
+}
+
+issue_2254_2: {
+    mangle = {
+        ie8: true,
+    }
+    input: {
+        "eeeeee";
+        try {
+            console.log(f("PASS"));
+        } catch (e) {}
+        function f(s) {
+            try {
+                throw "FAIL";
+            } catch (e) {
+                return s;
+            }
+        }
+    }
+    expect: {
+        "eeeeee";
+        try {
+            console.log(f("PASS"));
+        } catch (e) {}
+        function f(t) {
+            try {
+                throw "FAIL";
+            } catch (e) {
+                return t;
+            }
+        }
+    }
+    expect_stdout: "PASS"
+}