handle variable declaration within catch blocks (#1546)

accounts for IE8- scoping
This commit is contained in:
Alex Lam S.L
2017-03-05 13:13:44 +08:00
committed by GitHub
parent b33e7f88e6
commit b70591be1a
5 changed files with 69 additions and 6 deletions

View File

@@ -605,6 +605,29 @@ inner_var_for_in_2: {
}
}
inner_var_catch: {
options = {
evaluate: true,
reduce_vars: true,
}
input: {
try {
a();
} catch (e) {
var b = 1;
}
console.log(b);
}
expect: {
try {
a();
} catch (e) {
var b = 1;
}
console.log(b);
}
}
issue_1533_1: {
options = {
collapse_vars: true,

View File

@@ -148,3 +148,37 @@ dont_screw_try_catch_undefined: {
}
}
}
reduce_vars: {
options = {
evaluate: true,
reduce_vars: true,
screw_ie8: false,
unused: true,
}
mangle = {
screw_ie8: false,
}
input: {
function f() {
var a;
try {
x();
} catch (a) {
y();
}
alert(a);
}
}
expect: {
function f() {
var t;
try {
x();
} catch (t) {
y();
}
alert(t);
}
}
}