optimize try-catch-finally (#1731)

- eliminate empty blocks
- flatten out if try-block does not throw
This commit is contained in:
Alex Lam S.L
2017-03-30 12:16:58 +08:00
committed by GitHub
parent 0f910ee25c
commit 7bea38a05d
5 changed files with 81 additions and 12 deletions

View File

@@ -204,13 +204,13 @@ issue_1586_1: {
input: {
function f() {
try {
x();
} catch (err) {
console.log(err.message);
}
}
}
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
expect_stdout: true
expect_exact: "function f(){try{x()}catch(c){console.log(c.message)}}"
}
issue_1586_2: {
@@ -223,11 +223,11 @@ issue_1586_2: {
input: {
function f() {
try {
x();
} catch (err) {
console.log(err.message);
}
}
}
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
expect_stdout: true
expect_exact: "function f(){try{x()}catch(c){console.log(c.message)}}"
}