Skip to content

Commit ca49f6f

Browse files
authored
fix corner case in collapse_vars (#4853)
fixes #4852
1 parent 8a82822 commit ca49f6f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ merge(Compressor.prototype, {
18661866
return null;
18671867
}
18681868
default:
1869-
return;
1869+
return handle_custom_scan_order(node, multi_replacer);
18701870
}
18711871
}
18721872
// Replace variable when found

test/compress/collapse_vars.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8897,3 +8897,38 @@ issue_4806: {
88978897
}
88988898
expect_stdout: "PASS"
88998899
}
8900+
8901+
issue_4852: {
8902+
options = {
8903+
collapse_vars: true,
8904+
}
8905+
input: {
8906+
var a = "PASS";
8907+
(function(b) {
8908+
switch (b = a) {
8909+
case 42:
8910+
try {
8911+
console;
8912+
} catch (b) {
8913+
b.p;
8914+
}
8915+
case console.log(b):
8916+
}
8917+
})("FAIL");
8918+
}
8919+
expect: {
8920+
var a = "PASS";
8921+
(function(b) {
8922+
switch (a) {
8923+
case 42:
8924+
try {
8925+
console;
8926+
} catch (b) {
8927+
b.p;
8928+
}
8929+
case console.log(a):
8930+
}
8931+
})("FAIL");
8932+
}
8933+
expect_stdout: "PASS"
8934+
}

0 commit comments

Comments
 (0)