fix corner case in hoist_vars (#4860)

fixes #4859
This commit is contained in:
Alex Lam S.L
2021-04-21 22:47:21 +01:00
committed by GitHub
parent c58e174647
commit 3c161a6662
3 changed files with 37 additions and 10 deletions

View File

@@ -265,3 +265,32 @@ issue_4839: {
}
expect_stdout: "PASS"
}
issue_4859: {
options = {
evaluate: true,
hoist_vars: true,
keep_infinity: true,
merge_vars: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function f(a) {
var b = (a = 2, 1 / 0), c = 3;
var d = a + b;
console.log(d);
return f;
}
f();
}
expect: {
(function f(a) {
var d = 1 / 0, d = Infinity;
console.log(d);
return f;
})();
}
expect_stdout: "Infinity"
}