fix reduce_vars on catch variable (#1794)

Improved catch handling in `figure_out_scope()` means special case treatment of IE8 is no longer valid in `reset_opt_flags()`.

Also fixed recursive assignment in variable definition.
This commit is contained in:
Alex Lam S.L
2017-04-07 12:32:56 +08:00
committed by GitHub
parent cc6aa3e5ac
commit 281e882d27
2 changed files with 60 additions and 22 deletions

View File

@@ -1917,7 +1917,7 @@ side_effects_assign: {
expect_stdout: "undefined"
}
pure_getters: {
pure_getters_1: {
options = {
pure_getters: true,
reduce_vars: true,
@@ -1938,3 +1938,45 @@ pure_getters: {
}
expect_stdout: "undefined"
}
pure_getters_2: {
options = {
pure_getters: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a;
var a = a && a.b;
}
expect: {
var a;
var a = a && a.b;
}
}
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"
}