From: Vadim Zhestikov Date: Thu, 17 Nov 2022 00:09:47 +0000 (-0800) Subject: Fixed for-in unwanted detection of arrow function. X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=36f649b9715c13ac25dddadcf3ec752d7474ce08;p=njs.git Fixed for-in unwanted detection of arrow function. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 21cdf654..9d902863 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -4291,14 +4291,16 @@ njs_parser_assignment_expression(njs_parser_t *parser, { njs_int_t ret; - ret = njs_parser_match_arrow_expression(parser, token); - if (ret == NJS_OK) { - njs_parser_next(parser, njs_parser_arrow_function); + 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; + return NJS_OK; - } else if (ret == NJS_ERROR) { - return NJS_ERROR; + } else if (ret == NJS_ERROR) { + return NJS_ERROR; + } } njs_parser_next(parser, njs_parser_conditional_expression); diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 5ce4d075..364fcaa6 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -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"),