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

View File

@@ -2738,3 +2738,31 @@ issue_4135: {
}
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"
}