Fix function name evaluation order (#4830)
JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
This commit is contained in:
@@ -2248,7 +2248,8 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
|
|||||||
#endif /* JERRY_ESNEXT */
|
#endif /* JERRY_ESNEXT */
|
||||||
|
|
||||||
#if JERRY_ESNEXT
|
#if JERRY_ESNEXT
|
||||||
if (!CBC_FUNCTION_HAS_PROTOTYPE (bytecode_data_p->status_flags))
|
if (!CBC_FUNCTION_HAS_PROTOTYPE (bytecode_data_p->status_flags)
|
||||||
|
|| (CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags) == CBC_FUNCTION_CONSTRUCTOR))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,7 +520,8 @@ parser_is_constructor_literal (parser_context_t *context_p) /**< context */
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
parser_parse_class_body (parser_context_t *context_p, /**< context */
|
parser_parse_class_body (parser_context_t *context_p, /**< context */
|
||||||
parser_class_literal_opts_t opts) /**< class literal parsing options */
|
parser_class_literal_opts_t opts, /**< class literal parsing options */
|
||||||
|
uint16_t class_name_index) /**< class literal index */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (context_p->token.type == LEXER_LEFT_BRACE);
|
JERRY_ASSERT (context_p->token.type == LEXER_LEFT_BRACE);
|
||||||
|
|
||||||
@@ -541,6 +542,11 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
|
|||||||
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_IMPLICIT_CONSTRUCTOR);
|
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_IMPLICIT_CONSTRUCTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (class_name_index != PARSER_INVALID_LITERAL_INDEX)
|
||||||
|
{
|
||||||
|
parser_emit_cbc_ext_literal (context_p, CBC_EXT_SET_CLASS_NAME, class_name_index);
|
||||||
|
}
|
||||||
|
|
||||||
parser_emit_cbc_ext (context_p, CBC_EXT_INIT_CLASS);
|
parser_emit_cbc_ext (context_p, CBC_EXT_INIT_CLASS);
|
||||||
|
|
||||||
bool is_static = false;
|
bool is_static = false;
|
||||||
@@ -1014,12 +1020,11 @@ parser_parse_class (parser_context_t *context_p, /**< context */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ClassDeclaration is parsed. Continue with class body. */
|
/* ClassDeclaration is parsed. Continue with class body. */
|
||||||
bool has_static_field = parser_parse_class_body (context_p, opts);
|
bool has_static_field = parser_parse_class_body (context_p, opts, class_name_index);
|
||||||
|
|
||||||
if (class_name_index != PARSER_INVALID_LITERAL_INDEX)
|
if (class_name_index != PARSER_INVALID_LITERAL_INDEX)
|
||||||
{
|
{
|
||||||
parser_emit_cbc_ext_literal (context_p, CBC_EXT_FINALIZE_NAMED_CLASS, class_name_index);
|
parser_emit_cbc_ext_literal (context_p, CBC_EXT_FINALIZE_NAMED_CLASS, class_name_index);
|
||||||
parser_emit_cbc_ext_literal (context_p, CBC_EXT_SET_CLASS_NAME, class_name_index);
|
|
||||||
PARSER_MINUS_EQUAL_U16 (context_p->scope_stack_top, 1);
|
PARSER_MINUS_EQUAL_U16 (context_p->scope_stack_top, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -78,6 +78,6 @@ let C3 = class C4 {
|
|||||||
static yy = this
|
static yy = this
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Reflect.ownKeys(C3).toString() === "length,prototype,f,name,xx,yy")
|
assert(Reflect.ownKeys(C3).toString() === "length,name,prototype,f,xx,yy")
|
||||||
check_property(C3, "xx", C3)
|
check_property(C3, "xx", C3)
|
||||||
check_property(C3, "yy", C3)
|
check_property(C3, "yy", C3)
|
||||||
|
|||||||
@@ -335,4 +335,7 @@
|
|||||||
<test id="language/expressions/assignment/fn-name-lhs-member.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
<test id="language/expressions/assignment/fn-name-lhs-member.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
||||||
<test id="language/expressions/function/name.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
<test id="language/expressions/function/name.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
||||||
<test id="language/expressions/generators/name.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
<test id="language/expressions/generators/name.js"><reason>Outdated test, anonymous functions should now have a name property</reason></test>
|
||||||
|
<test id="language/computed-property-names/class/static/method-number.js"><reason>ES12 15.7.14.15.d: The evaluation order has been changed</reason></test>
|
||||||
|
<test id="language/computed-property-names/class/static/method-string.js"><reason>ES12 15.7.14.15.d: The evaluation order has been changed</reason></test>
|
||||||
|
<test id="language/computed-property-names/class/static/method-symbol.js"><reason>ES12 15.7.14.15.d: The evaluation order has been changed</reason></test>
|
||||||
</excludeList>
|
</excludeList>
|
||||||
|
|||||||
@@ -61,9 +61,6 @@
|
|||||||
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js"><reason></reason></test>
|
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js"><reason></reason></test>
|
||||||
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js"><reason></reason></test>
|
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js"><reason></reason></test>
|
||||||
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js"><reason></reason></test>
|
<test id="language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js"><reason></reason></test>
|
||||||
<test id="language/computed-property-names/class/static/method-number.js"><reason></reason></test>
|
|
||||||
<test id="language/computed-property-names/class/static/method-string.js"><reason></reason></test>
|
|
||||||
<test id="language/computed-property-names/class/static/method-symbol.js"><reason></reason></test>
|
|
||||||
<test id="language/eval-code/direct/non-definable-function-with-function.js"><reason></reason></test>
|
<test id="language/eval-code/direct/non-definable-function-with-function.js"><reason></reason></test>
|
||||||
<test id="language/eval-code/direct/non-definable-function-with-variable.js"><reason></reason></test>
|
<test id="language/eval-code/direct/non-definable-function-with-variable.js"><reason></reason></test>
|
||||||
<test id="language/eval-code/direct/non-definable-global-function.js"><reason></reason></test>
|
<test id="language/eval-code/direct/non-definable-global-function.js"><reason></reason></test>
|
||||||
|
|||||||
Reference in New Issue
Block a user