fix corner case in collapse_vars (#4853)

fixes #4852
This commit is contained in:
Alex Lam S.L
2021-04-08 10:50:40 +01:00
committed by GitHub
parent 8a82822654
commit ca49f6f41a
2 changed files with 36 additions and 1 deletions

View File

@@ -1866,7 +1866,7 @@ merge(Compressor.prototype, {
return null;
}
default:
return;
return handle_custom_scan_order(node, multi_replacer);
}
}
// Replace variable when found

View File

@@ -8897,3 +8897,38 @@ issue_4806: {
}
expect_stdout: "PASS"
}
issue_4852: {
options = {
collapse_vars: true,
}
input: {
var a = "PASS";
(function(b) {
switch (b = a) {
case 42:
try {
console;
} catch (b) {
b.p;
}
case console.log(b):
}
})("FAIL");
}
expect: {
var a = "PASS";
(function(b) {
switch (a) {
case 42:
try {
console;
} catch (b) {
b.p;
}
case console.log(a):
}
})("FAIL");
}
expect_stdout: "PASS"
}