Welcome! Log In Create A New Profile

Advanced

[njs] Rejection of multiple "var" declarations in the for-in statement.

Valentin Bartenev
May 02, 2019 04:52PM
details: https://hg.nginx.org/njs/rev/a9a4ffdea79c
branches:
changeset: 941:a9a4ffdea79c
user: Valentin Bartenev <vbart@nginx.com>
date: Thu May 02 21:21:16 2019 +0300
description:
Rejection of multiple "var" declarations in the for-in statement.

diffstat:

njs/njs_parser.c | 8 ++++++--
njs/test/njs_unit_test.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r ae95d2637819 -r a9a4ffdea79c njs/njs_parser.c
--- a/njs/njs_parser.c Thu May 02 11:08:44 2019 +0300
+++ b/njs/njs_parser.c Thu May 02 21:21:16 2019 +0300
@@ -1078,8 +1078,12 @@ njs_parser_var_statement(njs_vm_t *vm, n
return token;
}

- if (var_in && token == NJS_TOKEN_IN) {
- return njs_parser_var_in_statement(vm, parser, name);
+ if (var_in) {
+ if (token == NJS_TOKEN_IN) {
+ return njs_parser_var_in_statement(vm, parser, name);
+ }
+
+ var_in = 0;
}

expr = NULL;
diff -r ae95d2637819 -r a9a4ffdea79c njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Thu May 02 11:08:44 2019 +0300
+++ b/njs/test/njs_unit_test.c Thu May 02 21:21:16 2019 +0300
@@ -2265,6 +2265,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("for (null in undefined);"),
nxt_string("ReferenceError: Invalid left-hand side \"null\" in for-in statement in 1") },

+ { nxt_string("for (var a, b in []);"),
+ nxt_string("SyntaxError: Unexpected token \"in\" in 1") },
+
{ nxt_string("var s = ''; for (var p in [1,2]) {s += p}; s"),
nxt_string("01") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Rejection of multiple "var" declarations in the for-in statement.

Valentin Bartenev 430 May 02, 2019 04:52PM



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

Online Users

Guests: 224
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready