support arrow function (#4385)
This commit is contained in:
13
lib/scope.js
13
lib/scope.js
@@ -212,7 +212,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
argname.walk(tw);
|
||||
});
|
||||
in_arg.pop();
|
||||
walk_body(node, tw);
|
||||
if (node instanceof AST_Arrow && node.value) {
|
||||
node.value.walk(tw);
|
||||
} else {
|
||||
walk_body(node, tw);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_LoopControl) {
|
||||
@@ -249,7 +253,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
}
|
||||
if (!sym) {
|
||||
sym = self.def_global(node);
|
||||
} else if (name == "arguments" && sym.scope instanceof AST_Lambda) {
|
||||
} else if (name == "arguments"
|
||||
&& sym.orig[0] instanceof AST_SymbolFunarg
|
||||
&& !(sym.scope instanceof AST_Arrow)) {
|
||||
if (!(tw.parent() instanceof AST_PropAccess)) {
|
||||
sym.scope.uses_arguments = "d";
|
||||
} else if (!sym.scope.uses_arguments) {
|
||||
@@ -360,6 +366,9 @@ AST_BlockScope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
AST_Scope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
});
|
||||
AST_Arrow.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;
|
||||
|
||||
Reference in New Issue
Block a user