]> git.kaiwu.me - njs.git/commitdiff
Parser: catching errors parsing in await expression.
authorAlexander Borisov <alexander.borisov@nginx.com>
Thu, 2 Sep 2021 16:33:03 +0000 (19:33 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Thu, 2 Sep 2021 16:33:03 +0000 (19:33 +0300)
The bug was introduced in 92d10cd761e2.

src/njs_parser.c
src/test/njs_unit_test.c

index e02ae41365419eb20239fe056b429888e1f24632..8ea51c26ec7120b7085495971e3cfa02cf141a73 100644 (file)
@@ -3504,6 +3504,10 @@ static njs_int_t
 njs_parser_await_after(njs_parser_t *parser, njs_lexer_token_t *token,
     njs_queue_link_t *current)
 {
+    if (parser->ret != NJS_OK) {
+        return njs_parser_failed(parser);
+    }
+
     parser->target->right = parser->node;
     parser->node = parser->target;
 
index 3b5cb67e2b69ecc15c8b62dcd3b7850853bd3fab..3e0d4dcc86949ae664c28f8b33704d5f4aad0b43 100644 (file)
@@ -20517,6 +20517,9 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("function f(a) {}"
               "(async function() {f('Number: ' + await 111)})"),
       njs_str("SyntaxError: await in arguments not supported in 1") },
+
+    { njs_str("async function af() {await encrypt({},}"),
+      njs_str("SyntaxError: Unexpected token \"}\" in 1") },
 };