From: Vadim Zhestikov Date: Thu, 1 Jun 2023 16:39:27 +0000 (-0700) Subject: Fixed parsing of invalid for-var statement. X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=893c94e1a9ed0fc241722c831964ebb8bcb67ca3;p=njs.git Fixed parsing of invalid for-var statement. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 6c093c77..5a26a84a 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -5908,12 +5908,10 @@ njs_parser_for_var_binding_or_var_list(njs_parser_t *parser, njs_lexer_consume_token(parser->lexer, 2); return NJS_DONE; - } - - parser->node = NULL; - njs_parser_next(parser, njs_parser_expression); - return NJS_OK; + } else { + return njs_parser_failed(parser); + } } } diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 401fe558..d09275ce 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -2972,6 +2972,9 @@ static njs_unit_test_t njs_test[] = { njs_str("for(c=let c"), njs_str("SyntaxError: Unexpected token \"let\" in 1") }, + { njs_str("for(var``>0; 0 ;) ;"), + njs_str("SyntaxError: Unexpected token \"`\" in 1") }, + /* switch. */ { njs_str("switch"),