fix corner cases with block-scoped functions (#4695)

This commit is contained in:
Alex Lam S.L
2021-02-26 20:16:14 +00:00
committed by GitHub
parent ea52339502
commit ac26993b5a
6 changed files with 271 additions and 20 deletions

View File

@@ -327,6 +327,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
self.uses_eval = true;
}
}
if (sym.init instanceof AST_LambdaDefinition && sym.scope !== sym.init.name.scope) {
var scope = node.scope;
do {
if (scope === sym.init.name.scope) break;
} while (scope = scope.parent_scope);
if (!scope) sym.init = undefined;
}
node.thedef = sym;
node.reference(options);
return true;