Welcome! Log In Create A New Profile

Advanced

[njs] Parser: fixed parsing return statement without semicolon.

Alexander Borisov
July 14, 2020 07:52AM
details: https://hg.nginx.org/njs/rev/022995046310
branches:
changeset: 1464:022995046310
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Tue Jul 14 14:49:46 2020 +0300
description:
Parser: fixed parsing return statement without semicolon.

The issue was introduced in 86f55a7dc4a4.

This closes #330 issue on GitHub.

diffstat:

src/njs_parser.c | 3 +--
src/test/njs_unit_test.c | 3 +++
2 files changed, 4 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 5f2034557bc3 -r 022995046310 src/njs_parser.c
--- a/src/njs_parser.c Thu Jul 09 13:57:10 2020 +0000
+++ b/src/njs_parser.c Tue Jul 14 14:49:46 2020 +0300
@@ -5719,6 +5719,7 @@ njs_parser_return_statement(njs_parser_t

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->node = node;

- njs_lexer_consume_token(parser->lexer, 1);
-
return njs_parser_stack_pop(parser);
}

diff -r 5f2034557bc3 -r 022995046310 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Thu Jul 09 13:57:10 2020 +0000
+++ b/src/test/njs_unit_test.c Tue Jul 14 14:49:46 2020 +0300
@@ -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);"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Parser: fixed parsing return statement without semicolon.

Alexander Borisov 67 July 14, 2020 07:52AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 109
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready