fix corner case in merge_vars (#4140)

fixes #4139
This commit is contained in:
Alex Lam S.L
2020-09-21 23:49:41 +01:00
committed by GitHub
2 changed files with 32 additions and 6 deletions

View File

@@ -4413,13 +4413,10 @@ merge(Compressor.prototype, {
if (node instanceof AST_Scope) { if (node instanceof AST_Scope) {
push(); push();
segment.block = node; segment.block = node;
if (node instanceof AST_Lambda) { if (node instanceof AST_Lambda && node.name) {
if (node.name) {
if (node !== self) segment.loop = true; if (node !== self) segment.loop = true;
references[node.name.definition().id] = false; references[node.name.definition().id] = false;
} }
references[node.variables.get("arguments").id] = false;
}
descend(); descend();
pop(); pop();
return true; return true;
@@ -4538,6 +4535,7 @@ merge(Compressor.prototype, {
} }
function mark(sym, read, write) { function mark(sym, read, write) {
if (sym.name == "arguments") return;
var def = sym.definition(); var def = sym.definition();
if (def.id in references) { if (def.id in references) {
var refs = references[def.id]; var refs = references[def.id];

View File

@@ -2738,3 +2738,31 @@ issue_4135: {
} }
expect_stdout: "1 -1 undefined" expect_stdout: "1 -1 undefined"
} }
issue_4139: {
options = {
merge_vars: true,
toplevel: true,
}
input: {
try {
console.log;
} catch (e) {
var a, arguments = 0;
} finally {
a = typeof arguments;
console.log(a);
}
}
expect: {
try {
console.log;
} catch (e) {
var a, arguments = 0;
} finally {
a = typeof arguments;
console.log(a);
}
}
expect_stdout: "object"
}