From: Dmitry Volyntsev Date: Wed, 11 May 2022 23:33:46 +0000 (-0700) Subject: Fixed ellipsis support. X-Git-Tag: 0.7.4~11 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=3ebbfbcb0cbd3df889ea867537126e5988db4869;p=njs.git Fixed ellipsis support. As of now, ellispis syntax is supported for function declaration with the rest arguments. This closes #365 issue on Github. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 13c03b00..162736db 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -1664,12 +1664,18 @@ njs_parser_array_element_list(njs_parser_t *parser, njs_lexer_token_t *token, return NJS_OK; case NJS_TOKEN_ELLIPSIS: +#if 0 njs_lexer_consume_token(parser->lexer, 1); njs_parser_next(parser, njs_parser_assignment_expression); return njs_parser_after(parser, current, array, 0, njs_parser_array_spread_element); +#else + (void) njs_parser_array_spread_element; + return njs_parser_failed(parser); +#endif + default: break; } @@ -2862,9 +2868,11 @@ njs_parser_argument_list(njs_parser_t *parser, njs_lexer_token_t *token, * ArgumentList , ... AssignmentExpression */ +#if 0 /* TODO. */ if (token->type == NJS_TOKEN_ELLIPSIS) { njs_lexer_consume_token(parser->lexer, 1); } +#endif njs_parser_next(parser, njs_parser_assignment_expression); diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 490c0773..e80cd970 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -18041,9 +18041,14 @@ static njs_unit_test_t njs_test[] = { njs_str("[(]"), njs_str("SyntaxError: Unexpected token \"]\" in 1") }, +#if 0 /* TODO spreading support. */ { njs_str("[...]"), njs_str("SyntaxError: Unexpected token \"]\" in 1") }, + { njs_str("var id = (x) => x, x = id(...[1,2,3]); typeof x"), + njs_str("number") }, +#endif + { njs_str("switch () {}"), njs_str("SyntaxError: Unexpected token \")\" in 1") },