From 9ed695f9d29f841ae15f973e6e725d9c4b44ef51 Mon Sep 17 00:00:00 2001 From: Robert Sipka Date: Fri, 29 Oct 2021 09:52:30 +0200 Subject: [PATCH] Assignment Expression is not allowed in for of head's expression position (#4810) JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu --- jerry-core/parser/js/js-parser-statm.c | 3 ++- tests/jerry/es.next/for-of.js | 10 +++++++++- tests/test262-esnext-excludelist.xml | 3 --- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index b43304b1e..7f8aa7596 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -1289,7 +1289,8 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */ #endif /* JERRY_ESNEXT */ lexer_next_token (context_p); - parser_parse_expression (context_p, PARSE_EXPR); + int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_LEFT_HAND_SIDE; + parser_parse_expression (context_p, options); if (context_p->token.type != LEXER_RIGHT_PAREN) { diff --git a/tests/jerry/es.next/for-of.js b/tests/jerry/es.next/for-of.js index 97c450652..f00f4d794 100644 --- a/tests/jerry/es.next/for-of.js +++ b/tests/jerry/es.next/for-of.js @@ -56,7 +56,15 @@ var forOf = "for (var a \"of\" []) {}" parse (forOf) -checkError(5) +var forOf = + "for (let x of [], []) {}" +parse (forOf) + +var forOf = + "for (var x of [], []) {}" +parse (forOf) + +checkError(7) var obj = {} Object.defineProperty(obj, Symbol.iterator, { get : function () { throw TypeError ('foo');}}); diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 637564d21..5822d8849 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -343,9 +343,6 @@ - - -