fix corner case in ie8 (#4959)

fixes #4958
This commit is contained in:
Alex Lam S.L
2021-05-24 04:24:02 +01:00
committed by GitHub
parent eb08fed120
commit df47632ecc
2 changed files with 22 additions and 1 deletions

View File

@@ -409,13 +409,14 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
} else {
new_def = scope.def_variable(node);
}
if (new_def.undeclared) self.variables.set(name, new_def);
if (name == "arguments" && is_arguments(old_def) && node instanceof AST_SymbolLambda) return true;
old_def.defun = new_def.scope;
old_def.forEach(function(node) {
node.redef = old_def;
node.thedef = new_def;
node.reference(options);
});
if (new_def.undeclared) self.variables.set(name, new_def);
return true;
}
});

View File

@@ -2997,3 +2997,23 @@ issue_4928_2: {
}
expect_stdout: "PASS"
}
issue_4958: {
options = {
collapse_vars: true,
ie8: true,
}
input: {
console.log(function arguments(a) {
a = 21;
return arguments[0] + 21;
}("FAIL"));
}
expect: {
console.log(function arguments(a) {
a = 21;
return arguments[0] + 21;
}("FAIL"));
}
expect_stdout: "42"
}