return njs_parser_stack_pop(parser);
}
- parser->scope->in_args++;
-
njs_parser_next(parser, njs_parser_argument_list);
return njs_parser_after(parser, current, NULL, 1,
njs_parser_parenthesis_or_comma(njs_parser_t *parser, njs_lexer_token_t *token,
njs_queue_link_t *current)
{
- parser->scope->in_args--;
-
if (token->type == NJS_TOKEN_CLOSE_PARENTHESIS) {
njs_lexer_consume_token(parser->lexer, 1);
return njs_parser_stack_pop(parser);
return NJS_ERROR;
}
- if (parser->scope->in_args > 0) {
- njs_parser_syntax_error(parser, "await in arguments not supported");
- return NJS_ERROR;
- }
-
if (parser->scope->in_tagged_template > 0) {
njs_parser_syntax_error(parser,
"await in tagged template not supported");
njs_str("ReferenceError: \"AsyncFunction\" is not defined") },
{ njs_str("(async function() {console.log(await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("(async function() {console.log('Number: ' + await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("(async function() {f(await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("(async function() {f(f(1), await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("async () => [await x(1)(),]; async () => [await x(1)()]"),
njs_str("[object AsyncFunction]") },
{ njs_str("(async function() {f(1, 'a', await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("(async function() {f('Number: ' + await 111)})"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("[object AsyncFunction]") },
{ njs_str("async function f1() {try {f(await f1)} catch(e) {}}"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("undefined") },
{ njs_str("(async () => (function (){}) `${(async () => 1)(await 1)}`)()"),
- njs_str("SyntaxError: await in arguments not supported") },
+ njs_str("SyntaxError: await in tagged template not supported") },
{ njs_str("(async () => (function (){}) `${await 1}`)()"),
njs_str("SyntaxError: await in tagged template not supported") },
"f(1).then($r.retval)"),
njs_str("1") },
+ { njs_str("async function f() {"
+ " function g(v) { return v; }"
+ " return g(await Promise.resolve(1));"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("1") },
+
+ { njs_str("async function f() {"
+ " return ({"
+ " g(v) { return v; }"
+ " }).g(await Promise.resolve(2));"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("2") },
+
+ { njs_str("async function f() {"
+ " function g(a, b) { return a + b; }"
+ " return g(await Promise.resolve(1),"
+ " await Promise.resolve(2));"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("3") },
+
+ { njs_str("async function f() {"
+ " return ({"
+ " k: 10,"
+ " g(a, b) { return this.k + a + b; }"
+ " }).g(await Promise.resolve(1),"
+ " await Promise.resolve(2));"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("13") },
+
+ { njs_str("async function f() {"
+ " function C(v) { this.v = v; }"
+ " return (new C(await Promise.resolve(7))).v;"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("7") },
+
+ { njs_str("async function f() {"
+ " return ({"
+ " g(v) { return v; }"
+ " })?.g(await Promise.resolve(9));"
+ "}"
+ "f().then($r.retval)"),
+ njs_str("9") },
+
{ njs_str("$r.retval(Promise.all([async () => [await x('X')]]))"),
njs_str("[object Promise]") },