fix corner case in reduce_vars (#5062)

fixes #5061
This commit is contained in:
Alex Lam S.L
2021-07-08 09:31:04 +01:00
committed by GitHub
parent 6577d641ac
commit ea7829daf5
2 changed files with 53 additions and 0 deletions

View File

@@ -6346,3 +6346,55 @@ issue_5046: {
}
expect_stdout: "PASS"
}
issue_5061_1: {
options = {
evaluate: true,
reduce_vars: true,
toplevel: true,
}
input: {
var f, a = 1;
(f = function() {
console.log(a ? "foo" : "bar");
})();
f(a = 0);
}
expect: {
var f, a = 1;
(f = function() {
console.log(a ? "foo" : "bar");
})();
f(a = 0);
}
expect_stdout: [
"foo",
"bar",
]
}
issue_5061_2: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var f, a = 1;
(f = function() {
console.log(a ? "foo" : "bar");
})();
f(a = 0);
}
expect: {
var f, a = 1;
(f = function() {
console.log(a ? "foo" : "bar");
})();
f(a = 0);
}
expect_stdout: [
"foo",
"bar",
]
}