aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-18 01:42:07 +0000
committerGitHub <noreply@github.com>2020-12-18 09:42:07 +0800
commit82d2aa4acf1eea742a3b1041223a74b5960d4bfd (patch)
treeb9397db4dd8c4cd6cc20091fe0798d89da3a1bea /lib/scope.js
parentc1256c399a4db3228b461a742c66deb1ea5064e5 (diff)
downloadtracifyjs-82d2aa4acf1eea742a3b1041223a74b5960d4bfd.tar.gz
tracifyjs-82d2aa4acf1eea742a3b1041223a74b5960d4bfd.zip
fix corner case in `arguments` (#4398)
fixes #4397
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/scope.js b/lib/scope.js
index a285f919..187309ca 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -100,6 +100,8 @@ SymbolDef.prototype = {
},
};
+var unary_side_effects = makePredicate("delete ++ --");
+
AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
options = defaults(options, {
cache: null,
@@ -256,8 +258,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
} 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";
+ var parent = tw.parent();
+ if (parent instanceof AST_Assign && parent.left === node
+ || parent instanceof AST_Unary && unary_side_effects[parent.operator]) {
+ sym.scope.uses_arguments = 3;
+ } else if (sym.scope.uses_arguments < 2
+ && !(parent instanceof AST_PropAccess && parent.expression === node)) {
+ sym.scope.uses_arguments = 2;
} else if (!sym.scope.uses_arguments) {
sym.scope.uses_arguments = true;
}