fix corner case in merge_vars (#5421)

fixes #5420
This commit is contained in:
Alex Lam S.L
2022-04-17 23:38:08 +01:00
committed by GitHub
parent e396912ea2
commit 20252c6483
2 changed files with 30 additions and 3 deletions

View File

@@ -6246,9 +6246,7 @@ Compressor.prototype.compress = function(node) {
if (node instanceof AST_Try) {
var save_try = in_try;
in_try = node;
var save = segment;
walk_body(node, tw);
segment = save;
if (node.bcatch) {
if (node.bcatch.argname) node.bcatch.argname.mark_symbol(function(node) {
if (node instanceof AST_SymbolCatch) {
@@ -6266,7 +6264,6 @@ Compressor.prototype.compress = function(node) {
}
}
in_try = save_try;
segment = save;
if (node.bfinally) node.bfinally.walk(tw);
return true;
}

View File

@@ -3702,3 +3702,33 @@ issue_5182: {
]
node_version: ">=4"
}
issue_5420: {
options = {
merge_vars: true,
toplevel: true,
}
input: {
do {
var a = "FAIL 1";
a && a.p;
a = "FAIL 2";
try {
continue;
} catch (e) {}
var b = "FAIL 3";
} while (console.log(b || "PASS"));
}
expect: {
do {
var a = "FAIL 1";
a && a.p;
a = "FAIL 2";
try {
continue;
} catch (e) {}
var b = "FAIL 3";
} while (console.log(b || "PASS"));
}
expect_stdout: "PASS"
}