support asynchronous arrow functions (#4530)

This commit is contained in:
Alex Lam S.L
2021-01-10 03:34:26 +00:00
committed by GitHub
parent 0818d396c5
commit ba54d074d8
10 changed files with 159 additions and 56 deletions

View File

@@ -223,11 +223,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
});
if (node.rest) node.rest.walk(tw);
in_arg.pop();
if (node instanceof AST_Arrow && node.value) {
node.value.walk(tw);
} else {
walk_body(node, tw);
}
walk_lambda(node, tw);
return true;
}
if (node instanceof AST_LoopControl) {
@@ -328,7 +324,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
function is_arguments(sym) {
return sym.orig[0] instanceof AST_SymbolFunarg
&& !(sym.orig[1] instanceof AST_SymbolFunarg || sym.orig[2] instanceof AST_SymbolFunarg)
&& !(sym.scope instanceof AST_Arrow);
&& !is_arrow(sym.scope);
}
function redefine(node, scope) {
@@ -395,6 +391,9 @@ AST_Scope.DEFMETHOD("init_vars", function(parent_scope) {
AST_Arrow.DEFMETHOD("init_vars", function(parent_scope) {
init_scope_vars(this, parent_scope);
});
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent_scope) {
init_scope_vars(this, parent_scope);
});
AST_Lambda.DEFMETHOD("init_vars", function(parent_scope) {
init_scope_vars(this, parent_scope);
this.uses_arguments = false;