fix catch symbol mangling

Only need to look up the immediate parent for the same-name special case.

fixes #1733
This commit is contained in:
alexlamsl 2017-03-30 17:18:44 +08:00
parent 7cb1adf455
commit 6eb5e0381c
2 changed files with 42 additions and 1 deletions

View File

@ -81,7 +81,7 @@ SymbolDef.prototype = {
var def;
if (options.screw_ie8
&& sym instanceof AST_SymbolCatch
&& (def = s.parent_scope.find_variable(sym))) {
&& (def = s.parent_scope.variables.get(this.name))) {
this.mangled_name = def.mangled_name || def.name;
} else
this.mangled_name = s.next_mangled(options, this);

View File

@ -0,0 +1,41 @@
function_iife_catch: {
mangle = {
screw_ie8: true,
}
input: {
function f(n) {
!function() {
try {
throw 0;
} catch (n) {
var a = 1;
console.log(n, a);
}
}();
}
f();
}
expect_exact: "function f(o){!function(){try{throw 0}catch(c){var o=1;console.log(c,o)}}()}f();"
expect_stdout: "0 1"
}
function_iife_catch_ie8: {
mangle = {
screw_ie8: false,
}
input: {
function f(n) {
!function() {
try {
throw 0;
} catch (n) {
var a = 1;
console.log(n, a);
}
}();
}
f();
}
expect_exact: "function f(o){!function(){try{throw 0}catch(o){var c=1;console.log(o,c)}}()}f();"
expect_stdout: "0 1"
}