fix corner case in collapse_vars (#4587)

fixes #4586
This commit is contained in:
Alex Lam S.L
2021-01-23 23:05:43 +00:00
committed by GitHub
parent acc443b2cf
commit ef9f7ca3e7
2 changed files with 47 additions and 0 deletions

View File

@@ -8705,3 +8705,48 @@ collapse_or_assign: {
}
expect_stdout: "PASS"
}
issue_4586_1: {
options = {
collapse_vars: true,
}
input: {
var a = 42;
(function f(b) {
var b = a;
if (b === arguments[0])
console.log("PASS");
})(console);
}
expect: {
var a = 42;
(function f(b) {
var b = a;
if (b === arguments[0])
console.log("PASS");
})(console);
}
expect_stdout: "PASS"
}
issue_4586_2: {
options = {
collapse_vars: true,
}
input: {
var a = 42;
(function f(b) {
b = a;
if (b === arguments[0])
console.log("PASS");
})(console);
}
expect: {
var a = 42;
(function f(b) {
if ((b = a) === arguments[0])
console.log("PASS");
})(console);
}
expect_stdout: "PASS"
}