fix corner case in collapse_vars (#4896)

fixes #4895
This commit is contained in:
Alex Lam S.L
2021-05-02 11:23:18 +01:00
committed by GitHub
parent fb03561799
commit 4114431eec
2 changed files with 33 additions and 6 deletions

View File

@@ -8560,7 +8560,7 @@ issue_4047_1: {
expect: {
var b = 1;
var a;
console.log((a = --b + ((a = 0) !== typeof A), +void ((a >>= 0) && console.log("PASS"))));
console.log((a = --b + (0 !== typeof A), +void ((a >>= 0) && console.log("PASS"))));
}
expect_stdout: [
"PASS",
@@ -9085,3 +9085,25 @@ issue_4891: {
"0",
]
}
issue_4895: {
options = {
collapse_vars: true,
toplevel: true,
}
input: {
var a, b;
(function f() {
a = 42;
})();
console.log((b = a) || b, b += 0);
}
expect: {
var a, b;
(function f() {
a = 42;
})();
console.log((b = a) || b, b += 0);
}
expect_stdout: "42 42"
}