From: Alex Lam S.L Date: Fri, 30 Mar 2018 07:23:09 +0000 (+0900) Subject: mangle unused nested `AST_SymbolCatch` correctly (#3038) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fa3250199af84865363fc80a280ff035c7e495c6;p=UglifyJS.git mangle unused nested `AST_SymbolCatch` correctly (#3038) fixes #3035 --- diff --git a/lib/scope.js b/lib/scope.js index 7cbd82c1..a9431524 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -434,16 +434,19 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){ var redef = def.redefined(); if (redef) { redefined.push(def); - def.references.forEach(function(ref) { - ref.thedef = redef; - ref.reference(options); - ref.thedef = def; - }); + reference(node.argname); + def.references.forEach(reference); } descend(); if (!redef) mangle(def); return true; } + + function reference(sym) { + sym.thedef = redef; + sym.reference(options); + sym.thedef = def; + } }); this.walk(tw); redefined.forEach(mangle); diff --git a/test/compress/screw-ie8.js b/test/compress/ie8.js similarity index 85% rename from test/compress/screw-ie8.js rename to test/compress/ie8.js index 3a95eb6b..b21b8411 100644 --- a/test/compress/screw-ie8.js +++ b/test/compress/ie8.js @@ -464,3 +464,77 @@ issue_2976_2: { } expect_stdout: "PASS" } + +issue_3035: { + mangle = { + ie8: false, + } + input: { + var c = "FAIL"; + (function(a) { + try { + throw 1; + } catch (b) { + try { + throw 0; + } catch (a) { + b && (c = "PASS"); + } + } + })(); + console.log(c); + } + expect: { + var c = "FAIL"; + (function(o) { + try { + throw 1; + } catch (t) { + try { + throw 0; + } catch (o) { + t && (c = "PASS"); + } + } + })(); + console.log(c); + } + expect_stdout: "PASS" +} + +issue_3035_ie8: { + mangle = { + ie8: true, + } + input: { + var c = "FAIL"; + (function(a) { + try { + throw 1; + } catch (b) { + try { + throw 0; + } catch (a) { + b && (c = "PASS"); + } + } + })(); + console.log(c); + } + expect: { + var c = "FAIL"; + (function(t) { + try { + throw 1; + } catch (o) { + try { + throw 0; + } catch (t) { + o && (c = "PASS"); + } + } + })(); + console.log(c); + } + expect_stdout: "PASS" +}