Skip to content

Commit 9ed695f

Browse files
authored
Assignment Expression is not allowed in for of head's expression position (#4810)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent 3c742be commit 9ed695f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

jerry-core/parser/js/js-parser-statm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,8 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
12891289
#endif /* JERRY_ESNEXT */
12901290

12911291
lexer_next_token (context_p);
1292-
parser_parse_expression (context_p, PARSE_EXPR);
1292+
int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_LEFT_HAND_SIDE;
1293+
parser_parse_expression (context_p, options);
12931294

12941295
if (context_p->token.type != LEXER_RIGHT_PAREN)
12951296
{

tests/jerry/es.next/for-of.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ var forOf =
5656
"for (var a \"of\" []) {}"
5757
parse (forOf)
5858

59-
checkError(5)
59+
var forOf =
60+
"for (let x of [], []) {}"
61+
parse (forOf)
62+
63+
var forOf =
64+
"for (var x of [], []) {}"
65+
parse (forOf)
66+
67+
checkError(7)
6068

6169
var obj = {}
6270
Object.defineProperty(obj, Symbol.iterator, { get : function () { throw TypeError ('foo');}});

tests/test262-esnext-excludelist.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,6 @@
343343
<test id="language/statements/for-of/cptn-expr-abrupt-empty.js"><reason></reason></test>
344344
<test id="language/statements/for-of/cptn-expr-itr.js"><reason></reason></test>
345345
<test id="language/statements/for-of/cptn-expr-no-itr.js"><reason></reason></test>
346-
<test id="language/statements/for-of/head-decl-no-expr.js"><reason></reason></test>
347-
<test id="language/statements/for-of/head-expr-no-expr.js"><reason></reason></test>
348-
<test id="language/statements/for-of/head-var-no-expr.js"><reason></reason></test>
349346
<test id="language/statements/for-of/let-block-with-newline.js"><reason></reason></test>
350347
<test id="language/statements/for-of/let-identifier-with-newline.js"><reason></reason></test>
351348
<test id="language/statements/for-of/scope-body-lex-open.js"><reason></reason></test>

0 commit comments

Comments
 (0)