fix corner case in merge_vars (#4127)

fixes #4126
This commit is contained in:
Alex Lam S.L
2020-09-19 12:56:21 +01:00
committed by GitHub
parent 3ac533e644
commit 31c6b45036
2 changed files with 78 additions and 9 deletions

View File

@@ -2594,3 +2594,71 @@ cross_branch_2b_15: {
"bar",
]
}
issue_4126_1: {
options = {
merge_vars: true,
}
input: {
function f(a) {
try {
console.log("PASS");
} catch (e) {
var b = a;
} finally {
var c = b;
}
console.log(c);
}
f("FAIL");
}
expect: {
function f(a) {
try {
console.log("PASS");
} catch (e) {
var c = a;
} finally {
var c = c;
}
console.log(c);
}
f("FAIL");
}
expect_stdout: [
"PASS",
"undefined",
]
}
issue_4126_2: {
options = {
inline: true,
merge_vars: true,
side_effects: true,
toplevel: true,
}
input: {
try {
var a = function() {
var b = 0;
function f() {
b;
}
THROW(b);
}();
} catch (e) {
console.log(a);
}
}
expect: {
try {
var a = (b = 0, void THROW(b));
} catch (e) {
console.log(a);
}
function f() {}
var b;
}
expect_stdout: "undefined"
}