mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Check for prototype bound name in class static accessors (#4257)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
parent
d8955552d7
commit
080abb94ca
@ -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);
|
||||
}
|
||||
|
||||
@ -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()");
|
||||
|
||||
@ -301,7 +301,6 @@
|
||||
<test id="language/expressions/tagged-template/cache-identical-source-new-function.js"><reason></reason></test>
|
||||
<test id="language/line-terminators/S7.3_A2.3.js"><reason>No longer a SyntaxError in ES11</reason></test>
|
||||
<test id="language/line-terminators/S7.3_A2.4.js"><reason>No longer a SyntaxError in ES11</reason></test>
|
||||
<test id="language/statements/class/syntax/early-errors/class-body-static-method-get-propname-prototype.js"><reason></reason></test>
|
||||
<test id="language/statements/for-of/iterator-next-reference.js"><reason>ES2018 change: next method must be cached</reason></test>
|
||||
<test id="language/statements/for/S12.6.3_A9.1.js"><reason></reason></test>
|
||||
<test id="language/statements/for/S12.6.3_A9.js"><reason></reason></test>
|
||||
|
||||
@ -604,8 +604,6 @@
|
||||
<test id="language/expressions/class/dstr/meth-dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/dstr/meth-static-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/dstr/meth-static-dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/gen-method-length-dflt.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/gen-method-static/dflt-params-trailing-comma.js"><reason></reason></test>
|
||||
<test id="language/expressions/class/gen-method/dflt-params-trailing-comma.js"><reason></reason></test>
|
||||
@ -882,8 +880,6 @@
|
||||
<test id="language/statements/class/dstr/meth-dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/statements/class/dstr/meth-static-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/statements/class/dstr/meth-static-dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js"><reason></reason></test>
|
||||
<test id="language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js"><reason></reason></test>
|
||||
<test id="language/statements/class/gen-method-length-dflt.js"><reason></reason></test>
|
||||
<test id="language/statements/class/gen-method-static/dflt-params-trailing-comma.js"><reason></reason></test>
|
||||
<test id="language/statements/class/gen-method/dflt-params-trailing-comma.js"><reason></reason></test>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user