aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-08 04:59:08 +0000
committerGitHub <noreply@github.com>2020-12-08 12:59:08 +0800
commitfea9da9866478388dcb6f11d4a792d9aea4a23cd (patch)
tree2f7ca4229c8bbf7d286535311ef72275e5d94abc /lib
parent47331597825f3feb2915a0c0c789c4e7ea9b57e8 (diff)
downloadtracifyjs-fea9da9866478388dcb6f11d4a792d9aea4a23cd.tar.gz
tracifyjs-fea9da9866478388dcb6f11d4a792d9aea4a23cd.zip
forbid `AST_Await` in computed function arguments (#4352)
fixes #4351
Diffstat (limited to 'lib')
-rw-r--r--lib/parse.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 21e6055a..c65b2f42 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -653,14 +653,15 @@ function parse($TEXT, options) {
input : typeof $TEXT == "string"
? tokenizer($TEXT, options.filename, options.html5_comments, options.shebang)
: $TEXT,
- token : null,
- prev : null,
- peeked : null,
in_async : false,
- in_function : 0,
in_directives : true,
+ in_funarg : -1,
+ in_function : 0,
in_loop : 0,
- labels : []
+ labels : [],
+ peeked : null,
+ prev : null,
+ token : null,
};
S.token = next();
@@ -1053,9 +1054,12 @@ function parse($TEXT, options) {
if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
unexpected(prev());
expect("(");
+ var was_funarg = S.in_funarg;
+ S.in_funarg = S.in_function;
var argnames = expr_list(")", !options.strict, false, function() {
return maybe_destructured(AST_SymbolFunarg);
});
+ S.in_funarg = was_funarg;
var loop = S.in_loop;
var labels = S.labels;
++S.in_function;
@@ -1638,6 +1642,7 @@ function parse($TEXT, options) {
function maybe_await() {
var start = S.token;
if (!(S.in_async && is("name", "await"))) return maybe_unary();
+ if (S.in_funarg === S.in_function) croak("Invalid use of await in function argument");
S.input.context().regex_allowed = true;
next();
return new AST_Await({