fix reduce_vars on catch variable

Improved catch handling in `figure_out_scope()` means special case treatment of IE8 is no longer valid in `reset_opt_flags()`.
This commit is contained in:
alexlamsl 2017-04-07 05:33:42 +08:00
parent cc6aa3e5ac
commit 3f09efeeea
2 changed files with 26 additions and 2 deletions

View File

@ -251,7 +251,6 @@ merge(Compressor.prototype, {
AST_Node.DEFMETHOD("reset_opt_flags", function(compressor, rescan){
var reduce_vars = rescan && compressor.option("reduce_vars");
var toplevel = compressor.option("toplevel");
var ie8 = !compressor.option("screw_ie8");
var safe_ids = [];
push();
var suppressor = new TreeWalker(function(node) {
@ -277,7 +276,7 @@ merge(Compressor.prototype, {
d.fixed = false;
}
}
if (ie8 && node instanceof AST_SymbolCatch) {
if (node instanceof AST_SymbolCatch) {
node.definition().fixed = false;
}
if (node instanceof AST_VarDef) {

View File

@ -1938,3 +1938,28 @@ pure_getters: {
}
expect_stdout: "undefined"
}
catch_var: {
options = {
booleans: true,
evaluate: true,
reduce_vars: true,
}
input: {
try {
throw {};
} catch (e) {
var e;
console.log(!!e);
}
}
expect: {
try {
throw {};
} catch (e) {
var e;
console.log(!!e);
}
}
expect_stdout: "true"
}