Welcome! Log In Create A New Profile

Advanced

[njs] Fixed for-in unwanted detection of arrow function.

Vadim Zhestikov via nginx-devel
November 16, 2022 07:12PM
details: https://hg.nginx.org/njs/rev/487780764501
branches:
changeset: 2001:487780764501
user: Vadim Zhestikov <v.zhestikov@f5.com>
date: Wed Nov 16 16:09:47 2022 -0800
description:
Fixed for-in unwanted detection of arrow function.

diffstat:

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

diffs (41 lines):

diff -r 0d0b16ecf796 -r 487780764501 src/njs_parser.c
--- a/src/njs_parser.c Wed Nov 16 09:15:39 2022 -0800
+++ b/src/njs_parser.c Wed Nov 16 16:09:47 2022 -0800
@@ -4291,14 +4291,16 @@ njs_parser_assignment_expression(njs_par
{
njs_int_t ret;

- ret = njs_parser_match_arrow_expression(parser, token);
- if (ret == NJS_OK) {
- njs_parser_next(parser, njs_parser_arrow_function);
-
- return NJS_OK;
-
- } else if (ret == NJS_ERROR) {
- return NJS_ERROR;
+ if (!parser->use_lhs) {
+ ret = njs_parser_match_arrow_expression(parser, token);
+ if (ret == NJS_OK) {
+ njs_parser_next(parser, njs_parser_arrow_function);
+
+ return NJS_OK;
+
+ } else if (ret == NJS_ERROR) {
+ return NJS_ERROR;
+ }
}

njs_parser_next(parser, njs_parser_conditional_expression);
diff -r 0d0b16ecf796 -r 487780764501 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Wed Nov 16 09:15:39 2022 -0800
+++ b/src/test/njs_unit_test.c Wed Nov 16 16:09:47 2022 -0800
@@ -2965,6 +2965,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("for(I in``[)8"),
njs_str("SyntaxError: Unexpected token \")\" in 1") },

+ { njs_str("for(9A=>>"),
+ njs_str("SyntaxError: Unexpected token \"A\" in 1") },
+
/* switch. */

{ njs_str("switch"),
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Fixed for-in unwanted detection of arrow function.

Vadim Zhestikov via nginx-devel 160 November 16, 2022 07:12PM



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

Online Users

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