diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index 10a6bba1e..938a5cf38 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -621,8 +621,17 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */ { is_computed = true; } - else if (!is_static && parser_is_constructor_literal (context_p)) + else if (is_static) { + if (LEXER_IS_IDENT_OR_STRING (context_p->token.lit_location.type) + && lexer_compare_identifier_to_string (&context_p->token.lit_location, (uint8_t *) "prototype", 9)) + { + parser_raise_error (context_p, PARSER_ERR_CLASS_STATIC_PROTOTYPE); + } + } + else if (parser_is_constructor_literal (context_p)) + { + JERRY_ASSERT (!is_static); parser_raise_error (context_p, PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR); } @@ -705,7 +714,7 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */ { if (is_static) { - if (lexer_compare_literal_to_string (context_p, "prototype", 9)) + if (lexer_compare_identifier_to_string (&context_p->token.lit_location, (uint8_t *) "prototype", 9)) { parser_raise_error (context_p, PARSER_ERR_CLASS_STATIC_PROTOTYPE); } diff --git a/tests/jerry/es.next/class.js b/tests/jerry/es.next/class.js index 916f8ace9..2652e2546 100644 --- a/tests/jerry/es.next/class.js +++ b/tests/jerry/es.next/class.js @@ -49,6 +49,17 @@ must_throw("class class {}"); must_throw("class A { constructor() {} this.a = 5 }"); must_throw("class A { constructor() {} constructor() {} }"); must_throw("class A { static prototype() {} }"); +must_throw("class A { static get prototype() {} }"); +must_throw("class A { static set prototype() {} }"); +must_throw("class A { static prototyp\u{0065}() {} }"); +must_throw("class A { static get prototyp\u{0065}() {} }"); +must_throw("class A { static set prototyp\u{0065}() {} }"); +must_throw("class A { static 'prototype'() {} }"); +must_throw("class A { static get 'prototype'() {} }"); +must_throw("class A { static set 'prototype'() {} }"); +must_throw("class A { static 'prototyp\u{0065}'() {} }"); +must_throw("class A { static get 'prototyp\u{0065}'() {} }"); +must_throw("class A { static set 'prototyp\u{0065}'() {} }"); must_throw("class A { get constructor() {} }"); must_throw("class A { set constructor() {} }"); must_throw("class A {}; A()"); diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index 7d9bcc1ff..8b5458913 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -301,7 +301,6 @@ No longer a SyntaxError in ES11 No longer a SyntaxError in ES11 - ES2018 change: next method must be cached diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 0d39ccd10..e81a1bb80 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -604,8 +604,6 @@ - - @@ -882,8 +880,6 @@ - -