diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse.js | 15 |
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({ |