diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c
index 01347abdc..3168ac7de 100644
--- a/jerry-core/ecma/operations/ecma-function-object.c
+++ b/jerry-core/ecma/operations/ecma-function-object.c
@@ -1324,6 +1324,11 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
message_p = ECMA_ERR_MSG ("Async arrow functions cannot be invoked with 'new'.");
break;
}
+ case CBC_FUNCTION_METHOD:
+ {
+ message_p = ECMA_ERR_MSG ("Methods cannot be invoked with 'new'.");
+ break;
+ }
default:
{
JERRY_ASSERT (CBC_FUNCTION_GET_TYPE (byte_code_p->status_flags) == CBC_FUNCTION_ACCESSOR);
diff --git a/jerry-core/parser/js/byte-code.h b/jerry-core/parser/js/byte-code.h
index 936dbc6fa..3302eb28f 100644
--- a/jerry-core/parser/js/byte-code.h
+++ b/jerry-core/parser/js/byte-code.h
@@ -880,6 +880,7 @@ typedef enum
/* The following functions has no prototype (see CBC_FUNCTION_HAS_PROTOTYPE) */
CBC_FUNCTION_ACCESSOR, /**< property accessor function */
+ CBC_FUNCTION_METHOD, /**< method */
/* The following functions are arrow function (see CBC_FUNCTION_IS_ARROW) */
CBC_FUNCTION_ARROW, /**< arrow function */
diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c
index 499585c7a..9e62c3028 100644
--- a/jerry-core/parser/js/js-parser-expr.c
+++ b/jerry-core/parser/js/js-parser-expr.c
@@ -743,7 +743,7 @@ parser_parse_class_literal (parser_context_t *context_p, /**< context */
parse_class_method:
; /* Empty statement to make compiler happy. */
uint16_t literal_index = context_p->lit_object.index;
- uint16_t function_literal_index = lexer_construct_function_object (context_p, status_flags);
+ uint16_t function_literal_index = lexer_construct_function_object (context_p, status_flags | PARSER_IS_METHOD);
parser_emit_cbc_literal (context_p,
CBC_PUSH_LITERAL,
@@ -915,7 +915,8 @@ parser_parse_object_method (parser_context_t *context_p) /**< context */
context_p->source_p--;
context_p->column--;
uint16_t function_literal_index = lexer_construct_function_object (context_p, (PARSER_FUNCTION_CLOSURE
- | PARSER_ALLOW_SUPER));
+ | PARSER_ALLOW_SUPER
+ | PARSER_IS_METHOD));
parser_emit_cbc_literal (context_p,
CBC_PUSH_LITERAL,
diff --git a/jerry-core/parser/js/js-parser-internal.h b/jerry-core/parser/js/js-parser-internal.h
index 898eebad6..e6af2c21e 100644
--- a/jerry-core/parser/js/js-parser-internal.h
+++ b/jerry-core/parser/js/js-parser-internal.h
@@ -74,11 +74,11 @@ typedef enum
PARSER_ALLOW_SUPER_CALL = (1u << 22), /**< allow super constructor call
* Note: PARSER_CLASS_CONSTRUCTOR must be present */
PARSER_ALLOW_NEW_TARGET = (1u << 23), /**< allow new.target parsing in the current context */
-
+ PARSER_IS_METHOD = (1u << 24), /**< method is parsed */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_MODULE_SYSTEM)
- PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 24), /**< parsing a function or class default export */
- PARSER_MODULE_STORE_IDENT = (1u << 25), /**< store identifier of the current export statement */
+ PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 25), /**< parsing a function or class default export */
+ PARSER_MODULE_STORE_IDENT = (1u << 26), /**< store identifier of the current export statement */
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
PARSER_HAS_LATE_LIT_INIT = (1u << 30), /**< there are identifier or string literals which construction
* is postponed after the local parser data is freed */
diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c
index 9de28e84b..6d1e215df 100644
--- a/jerry-core/parser/js/js-parser.c
+++ b/jerry-core/parser/js/js-parser.c
@@ -1405,6 +1405,10 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_CONSTRUCTOR);
}
+ else if (context_p->status_flags & PARSER_IS_METHOD)
+ {
+ function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_METHOD);
+ }
else
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_NORMAL);
diff --git a/tests/jerry/es.next/regression-test-issue-3459.js b/tests/jerry/es.next/regression-test-issue-3459.js
index 7bb686e36..7199e222d 100644
--- a/tests/jerry/es.next/regression-test-issue-3459.js
+++ b/tests/jerry/es.next/regression-test-issue-3459.js
@@ -18,4 +18,8 @@ class MyNonArray extends Array {
static [Symbol.species] () {}
}
-(() => MyNonArray)().prototype.slice.call(new MyNonArray((0) === 1))
+try {
+ (() => MyNonArray)().prototype.slice.call(new MyNonArray((0) === 1))
+} catch (e) {
+ assert (e instanceof TypeError);
+}
diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml
index 01ecd2ad9..950a74389 100644
--- a/tests/test262-es6-excludelist.xml
+++ b/tests/test262-es6-excludelist.xml
@@ -286,9 +286,7 @@
-
-
-
+ ES2016 change: Generator methods isn't constructor - https://github.com/tc39/ecma262/pull/171
@@ -324,8 +322,6 @@
No longer a SyntaxError in ES11
-
-
diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml
index 5eef25599..377092e9e 100644
--- a/tests/test262-esnext-excludelist.xml
+++ b/tests/test262-esnext-excludelist.xml
@@ -6779,9 +6779,7 @@
-
-
@@ -7413,8 +7411,6 @@
-
-