From 7ea0000ee0b5b5a6dc58b70b3412a8b653bca1e8 Mon Sep 17 00:00:00 2001 From: Robert Sipka Date: Tue, 2 Nov 2021 19:12:30 +0100 Subject: [PATCH] Minor fix in for-of statement parsing (#4814) JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu --- jerry-core/parser/js/js-parser-statm.c | 2 +- tests/jerry/es.next/for-of-statement-head.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/jerry/es.next/for-of-statement-head.js diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index acedf39b9..e648960c4 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -1289,7 +1289,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */ #endif /* JERRY_ESNEXT */ lexer_next_token (context_p); - int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_LEFT_HAND_SIDE; + int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_NO_COMMA; parser_parse_expression (context_p, options); if (context_p->token.type != LEXER_RIGHT_PAREN) diff --git a/tests/jerry/es.next/for-of-statement-head.js b/tests/jerry/es.next/for-of-statement-head.js new file mode 100644 index 000000000..ea7d63b47 --- /dev/null +++ b/tests/jerry/es.next/for-of-statement-head.js @@ -0,0 +1,16 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +for (a of [1] || [2]) {} +