diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-04-10 23:36:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 06:36:17 +0800 |
commit | c810ecd0810c86dc9cd25b443c33aa998649e390 (patch) | |
tree | b8d6db489ae07609369622795770d4f86a0c1d53 /lib/scope.js | |
parent | dce9dfce0e5b75812f2ff62cd9c80b8c9598b05a (diff) | |
download | tracifyjs-c810ecd0810c86dc9cd25b443c33aa998649e390.tar.gz tracifyjs-c810ecd0810c86dc9cd25b443c33aa998649e390.zip |
improve handling of `eval` (#3776)
closes #3768
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/scope.js b/lib/scope.js index 35d97e12..ad33c5e0 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -162,17 +162,22 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { } if (node instanceof AST_SymbolRef) { var name = node.name; - if (name == "eval" && tw.parent() instanceof AST_Call) { - for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) { - s.uses_eval = true; - } - } var sym = node.scope.find_variable(name); if (!sym) { sym = self.def_global(node); } else if (sym.scope instanceof AST_Lambda && name == "arguments") { sym.scope.uses_arguments = true; } + if (name == "eval") { + var parent = tw.parent(); + if (parent.TYPE == "Call" && parent.expression === node) { + for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) { + s.uses_eval = true; + } + } else if (sym.undeclared) { + self.uses_eval = true; + } + } node.thedef = sym; node.reference(options); return true; |