Skip to content

Commit e9df2ca

Browse files
author
kisbg
authored
Add newtarget support AsyncFunction (#4560)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis [email protected]
1 parent dd698f8 commit e9df2ca

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

jerry-core/ecma/operations/ecma-function-object.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -492,28 +492,28 @@ ecma_op_create_dynamic_function (const ecma_value_t *arguments_list_p, /**< argu
492492

493493
#if ENABLED (JERRY_ESNEXT)
494494
ecma_object_t *new_target_p = JERRY_CONTEXT (current_new_target_p);
495+
ecma_builtin_id_t fallback_ctor = ECMA_BUILTIN_ID_FUNCTION;
495496

496497
if (JERRY_UNLIKELY (parse_opts & (ECMA_PARSE_GENERATOR_FUNCTION | ECMA_PARSE_ASYNC_FUNCTION)))
497498
{
498-
fallback_proto = ECMA_BUILTIN_ID_GENERATOR;
499+
fallback_proto = ECMA_BUILTIN_ID_ASYNC_GENERATOR;
500+
fallback_ctor = ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION;
499501

500-
if (parse_opts & ECMA_PARSE_ASYNC_FUNCTION)
502+
if (!(parse_opts & ECMA_PARSE_GENERATOR_FUNCTION))
501503
{
502-
fallback_proto = ECMA_BUILTIN_ID_ASYNC_GENERATOR;
503-
504-
if (new_target_p == NULL)
505-
{
506-
new_target_p = ecma_builtin_get (ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION);
507-
}
504+
fallback_proto = ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE;
505+
fallback_ctor = ECMA_BUILTIN_ID_ASYNC_FUNCTION;
508506
}
509-
else if (new_target_p == NULL)
507+
else if (!(parse_opts & ECMA_PARSE_ASYNC_FUNCTION))
510508
{
511-
new_target_p = ecma_builtin_get (ECMA_BUILTIN_ID_GENERATOR_FUNCTION);
509+
fallback_proto = ECMA_BUILTIN_ID_GENERATOR;
510+
fallback_ctor = ECMA_BUILTIN_ID_GENERATOR_FUNCTION;
512511
}
513512
}
514-
else if (new_target_p == NULL)
513+
514+
if (new_target_p == NULL)
515515
{
516-
new_target_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION);
516+
new_target_p = ecma_builtin_get (fallback_ctor);
517517
}
518518

519519
ecma_object_t *proto = ecma_op_get_prototype_from_constructor (new_target_p, fallback_proto);

tests/test262-esnext-excludelist.xml

-2
Original file line numberDiff line numberDiff line change
@@ -8487,7 +8487,6 @@
84878487
<test id="annexB/language/statements/const/dstr/object-pattern-emulates-undefined.js"><reason></reason></test>
84888488
<test id="annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js"><reason></reason></test>
84898489
<test id="annexB/language/statements/function/default-parameters-emulates-undefined.js"><reason></reason></test>
8490-
<test id="built-ins/AsyncFunction/proto-from-ctor-realm.js"><reason></reason></test>
84918490
<test id="built-ins/Atomics/notify/bigint/notify-all-on-loc.js"><reason></reason></test>
84928491
<test id="built-ins/Atomics/notify/count-defaults-to-infinity-missing.js"><reason></reason></test>
84938492
<test id="built-ins/Atomics/notify/count-defaults-to-infinity-undefined.js"><reason></reason></test>
@@ -8738,5 +8737,4 @@
87388737
<test id="built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js"><reason></reason></test>
87398738
<test id="built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js"><reason></reason></test>
87408739
<!-- END - Missing test262 support in JerryScript REPL - missing $262.detachArrayBuffer function -->
8741-
87428740
</excludeList>

0 commit comments

Comments
 (0)