aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-16 20:11:57 +0100
committerGitHub <noreply@github.com>2020-09-17 03:11:57 +0800
commit2a053710bdafde88c305d318ed2e0196d5dcdfc7 (patch)
tree30e1ef02238f5c1dfcadc110da218ddad266b9d9
parent219aac6a84d357b1bd8fa5eb3ba754bf6cfa6498 (diff)
downloadtracifyjs-2a053710bdafde88c305d318ed2e0196d5dcdfc7.tar.gz
tracifyjs-2a053710bdafde88c305d318ed2e0196d5dcdfc7.zip
fix corner case in `merge_vars` (#4116)
fixes #4115
-rw-r--r--lib/compress.js6
-rw-r--r--test/compress/merge_vars.js26
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index a79b909d..e3139054 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4376,6 +4376,12 @@ merge(Compressor.prototype, {
pop();
return true;
}
+ if (node instanceof AST_LabeledStatement) {
+ push();
+ node.body.walk(tw);
+ pop();
+ return true;
+ }
if (node instanceof AST_Scope) {
if (node instanceof AST_Lambda) {
references[node.variables.get("arguments").id] = false;
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js
index fd650f9d..c63f33d0 100644
--- a/test/compress/merge_vars.js
+++ b/test/compress/merge_vars.js
@@ -486,3 +486,29 @@ issue_4112: {
}
expect_stdout: "function"
}
+
+issue_4115: {
+ options = {
+ merge_vars: true,
+ toplevel: true,
+ }
+ input: {
+ L: {
+ var o = typeof console;
+ for (var k in o)
+ break L;
+ var a = 0;
+ }
+ console.log(typeof a);
+ }
+ expect: {
+ L: {
+ var o = typeof console;
+ for (var k in o)
+ break L;
+ var a = 0;
+ }
+ console.log(typeof a);
+ }
+ expect_stdout: "undefined"
+}