From: Alexander Borisov Date: Tue, 14 Jul 2020 11:49:46 +0000 (+0300) Subject: Parser: fixed parsing return statement without semicolon. X-Git-Tag: 0.4.3~24 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=ad26dbe7fc3701895bb1e74d1607ff0b9ec587dd;p=njs.git Parser: fixed parsing return statement without semicolon. The issue was introduced in 86f55a7dc4a4. This closes #330 issue on GitHub. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index af2a8948..5fb5a863 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -5719,6 +5719,7 @@ njs_parser_return_statement(njs_parser_t *parser, njs_lexer_token_t *token, switch (token->type) { case NJS_TOKEN_SEMICOLON: + njs_lexer_consume_token(parser->lexer, 1); break; case NJS_TOKEN_LINE_END: @@ -5741,8 +5742,6 @@ njs_parser_return_statement(njs_parser_t *parser, njs_lexer_token_t *token, parser->node = node; - njs_lexer_consume_token(parser->lexer, 1); - return njs_parser_stack_pop(parser); } diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 65d0000c..ba444b9a 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -2553,6 +2553,9 @@ static njs_unit_test_t njs_test[] = { njs_str("var x = 0, y = 2; x\n--\ny; [x,y]"), njs_str("0,1") }, + { njs_str("function f() {return\n}"), + njs_str("undefined") }, + /* if. */ { njs_str("if (0);"),