fix corner cases in reduce_vars & unused (#3955)

fixes #3953
fixes #3956
fixes #3957
This commit is contained in:
Alex Lam S.L
2020-06-05 11:51:21 +01:00
committed by GitHub
parent fbc9d8009b
commit eb481cee8c
4 changed files with 124 additions and 10 deletions

View File

@@ -7273,3 +7273,53 @@ local_assignment_loop: {
}
expect_stdout: "PASS"
}
issue_3957_1: {
options = {
evaluate: true,
reduce_vars: true,
}
input: {
function f(a) {
while (a += console.log(a = 0))
a = 0;
}
f("FAIL");
}
expect: {
function f(a) {
while (a += console.log(a = 0))
a = 0;
}
f("FAIL");
}
expect_stdout: [
"0",
"0",
]
}
issue_3957_2: {
options = {
reduce_vars: true,
unused: true,
}
input: {
function f(a) {
while (a += console.log(a = 0))
a = 0;
}
f("FAIL");
}
expect: {
function f(a) {
while (a += console.log(a = 0))
a = 0;
}
f("FAIL");
}
expect_stdout: [
"0",
"0",
]
}