Alexander Borisov
June 15, 2020 11:36AM
details: https://hg.nginx.org/njs/rev/3bfa26b91a55
branches:
changeset: 1432:3bfa26b91a55
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Mon Jun 15 18:33:57 2020 +0300
description:
Parser: fixed semicolon check after continue/break statement.

This closes #318 issue on GitHub.

diffstat:

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

diffs (44 lines):

diff -r 6023201cf1f3 -r 3bfa26b91a55 src/njs_parser.c
--- a/src/njs_parser.c Mon Jun 15 15:26:44 2020 +0000
+++ b/src/njs_parser.c Mon Jun 15 18:33:57 2020 +0300
@@ -5645,13 +5645,11 @@ njs_parser_break_continue(njs_parser_t *
return njs_parser_failed(parser);

default:
- if (!parser->strict_semicolon
- && parser->lexer->prev_type == NJS_TOKEN_LINE_END)
- {
- break;
- }
-
if (njs_lexer_token_is_label_identifier(token)) {
+ if (parser->lexer->prev_type == NJS_TOKEN_LINE_END) {
+ return njs_parser_stack_pop(parser);
+ }
+
if (njs_label_find(parser->vm, parser->scope,
token->unique_id) == NULL)
{
diff -r 6023201cf1f3 -r 3bfa26b91a55 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Mon Jun 15 15:26:44 2020 +0000
+++ b/src/test/njs_unit_test.c Mon Jun 15 18:33:57 2020 +0300
@@ -2828,6 +2828,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("var i; for (i in [1,2,3]) {Object.seal({});}"),
njs_str("undefined") },

+ { njs_str("while (0) {continue\n}"),
+ njs_str("undefined") },
+
/* break. */

{ njs_str("break"),
@@ -2896,6 +2899,9 @@ static njs_unit_test_t njs_test[] =
"for (i in a) if (a[i] > 4) break; s += a[i]; s"),
njs_str("5") },

+ { njs_str("while (0) {break\n}"),
+ njs_str("undefined") },
+
/* Labels. */

{ njs_str("var n = 0; a:{n++}; a:{n++}; n"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Parser: fixed semicolon check after continue/break statement.

Alexander Borisov 123 June 15, 2020 11:36AM



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

Online Users

Guests: 98
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