diff options
author | Robert Sipka <robert.sipka@h-lab.eu> | 2021-10-26 16:03:39 +0200 |
---|---|---|
committer | Robert Sipka <robert.sipka@h-lab.eu> | 2021-10-27 09:11:45 +0200 |
commit | 13b20ab0091310ccb0482d3e9973ac093ccc263c (patch) | |
tree | 517a6c82195b1a79633986a79d65916f4423b05c | |
parent | 100b6f577ef1c391fca016e4a5ed4b75affa7447 (diff) |
Declaration in the head of a for-of loop can't have an initializerhead_init_for-of
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu
-rw-r--r-- | jerry-core/parser/js/js-parser-statm.c | 2 | ||||
-rw-r--r-- | tests/jerry/initializer-in-for-of-statement-head.js | 25 | ||||
-rw-r--r-- | tests/test262-esnext-excludelist.xml | 6 |
3 files changed, 26 insertions, 7 deletions
diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index 4c00fdc3..9b0da325 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -1414,7 +1414,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */ if (context_p->token.type == LEXER_ASSIGN) { #if JERRY_ESNEXT - if (context_p->status_flags & PARSER_IS_STRICT) + if ((context_p->status_flags & PARSER_IS_STRICT) || !is_for_in) { parser_raise_error (context_p, PARSER_ERR_FOR_IN_OF_DECLARATION); } diff --git a/tests/jerry/initializer-in-for-of-statement-head.js b/tests/jerry/initializer-in-for-of-statement-head.js new file mode 100644 index 00000000..3bcdd682 --- /dev/null +++ b/tests/jerry/initializer-in-for-of-statement-head.js @@ -0,0 +1,25 @@ +/* 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. + */ + +function parse(txt) { + try { + eval(txt) + assert(false) + } catch (e) { + assert(e instanceof SyntaxError) + } +} + +parse("for (var x = 1 of []) { }") diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index a8a95dc6..aaa42b9f 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -343,11 +343,8 @@ <test id="language/statements/for-of/cptn-expr-abrupt-empty.js"><reason></reason></test> <test id="language/statements/for-of/cptn-expr-itr.js"><reason></reason></test> <test id="language/statements/for-of/cptn-expr-no-itr.js"><reason></reason></test> - <test id="language/statements/for-of/head-const-init.js"><reason></reason></test> <test id="language/statements/for-of/head-decl-no-expr.js"><reason></reason></test> <test id="language/statements/for-of/head-expr-no-expr.js"><reason></reason></test> - <test id="language/statements/for-of/head-let-init.js"><reason></reason></test> - <test id="language/statements/for-of/head-var-init.js"><reason></reason></test> <test id="language/statements/for-of/head-var-no-expr.js"><reason></reason></test> <test id="language/statements/for-of/let-block-with-newline.js"><reason></reason></test> <test id="language/statements/for-of/let-identifier-with-newline.js"><reason></reason></test> @@ -7702,9 +7699,6 @@ <test id="language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js"><reason></reason></test> <test id="language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js"><reason></reason></test> <test id="language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js"><reason></reason></test> - <test id="language/statements/for-await-of/head-const-init.js"><reason></reason></test> - <test id="language/statements/for-await-of/head-let-init.js"><reason></reason></test> - <test id="language/statements/for-await-of/head-var-init.js"><reason></reason></test> <test id="language/statements/for-await-of/let-block-with-newline.js"><reason></reason></test> <test id="language/statements/for-await-of/let-identifier-with-newline.js"><reason></reason></test> <test id="language/statements/for-await-of/ticks-with-sync-iter-resolved-promise-and-constructor-lookup.js"><reason></reason></test> |