aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-04-08 10:50:40 +0100
committerGitHub <noreply@github.com>2021-04-08 17:50:40 +0800
commitca49f6f41a4b515b60a4b5784ae650b1b6cf0322 (patch)
tree039be055edd3a29c52a4954dca74eeffba50b07a
parent8a828226547bcb898b95b69a3f55f6a0dc74d592 (diff)
downloadtracifyjs-ca49f6f41a4b515b60a4b5784ae650b1b6cf0322.tar.gz
tracifyjs-ca49f6f41a4b515b60a4b5784ae650b1b6cf0322.zip
fix corner case in `collapse_vars` (#4853)
fixes #4852
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/collapse_vars.js35
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 21eec7c3..911cf554 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1866,7 +1866,7 @@ merge(Compressor.prototype, {
return null;
}
default:
- return;
+ return handle_custom_scan_order(node, multi_replacer);
}
}
// Replace variable when found
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index eaff0127..fcc47391 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -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"
+}