[Pkg-javascript-commits] [uglifyjs] 101/228: fix catch variable reference in IE8 (#1587)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit 9e6b128374c62ee9f6238134fdc207ec9dc86284
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Mar 10 03:15:21 2017 +0800

    fix catch variable reference in IE8 (#1587)
    
    `AST_Scope.def_variable()` will overwrite `AST_Symbol.thedef`, so save a copy before calling.
    
    fixes #1586
---
 lib/scope.js               |  3 ++-
 test/compress/screw-ie8.js | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/lib/scope.js b/lib/scope.js
index f23c8fe..483503e 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -212,9 +212,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
         self.walk(new TreeWalker(function(node, descend) {
             if (node instanceof AST_SymbolCatch) {
                 var name = node.name;
+                var refs = node.thedef.references;
                 var scope = node.thedef.scope.parent_scope;
                 var def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
-                node.thedef.references.forEach(function(ref) {
+                refs.forEach(function(ref) {
                     ref.thedef = def;
                     ref.reference(options);
                 });
diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js
index 36eb4d3..4fbb95c 100644
--- a/test/compress/screw-ie8.js
+++ b/test/compress/screw-ie8.js
@@ -182,3 +182,39 @@ reduce_vars: {
         }
     }
 }
+
+issue_1586_1: {
+    options = {
+        screw_ie8: false,
+    }
+    mangle = {
+        screw_ie8: false,
+    }
+    input: {
+        function f() {
+            try {
+            } catch (err) {
+                console.log(err.message);
+            }
+        }
+    }
+    expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
+}
+
+issue_1586_2: {
+    options = {
+        screw_ie8: true,
+    }
+    mangle = {
+        screw_ie8: true,
+    }
+    input: {
+        function f() {
+            try {
+            } catch (err) {
+                console.log(err.message);
+            }
+        }
+    }
+    expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list