fix corner case in dead_code (#5642)

fixes #5641
This commit is contained in:
Alex Lam S.L
2022-09-03 23:18:25 +01:00
committed by GitHub
parent e012f046bc
commit 78f354beb8
2 changed files with 42 additions and 7 deletions

View File

@@ -1705,3 +1705,28 @@ issue_5506: {
"bar",
]
}
issue_5641: {
options = {
collapse_vars: true,
conditionals: true,
dead_code: true,
}
input: {
function f(a) {
if (a || b) {
var b = "PASS", c = b && console.log(b);
} else
var d = a || b;
}
f(42);
}
expect: {
function f(a) {
var b, c, d;
(a || b) && (b = "PASS") && console.log(b);
}
f(42);
}
expect_stdout: "PASS"
}