aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-17 10:23:41 +0000
committerGitHub <noreply@github.com>2020-12-17 18:23:41 +0800
commita96f087ac33b6d18d5ffa3cacd39dd693defb7cf (patch)
treed670eab7971cb7bf27e029319db0357ff38e51d5 /lib/scope.js
parent75e9fd84174eaa8bf97975ad254fe06958564547 (diff)
downloadtracifyjs-a96f087ac33b6d18d5ffa3cacd39dd693defb7cf.tar.gz
tracifyjs-a96f087ac33b6d18d5ffa3cacd39dd693defb7cf.zip
support arrow function (#4385)
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/scope.js b/lib/scope.js
index ff0cb58c..a285f919 100644
--- a/lib/scope.js
+++ b/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;