From d1f73752ff742c52755488ba62e4c6cec45dc141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Sat, 10 Oct 2020 18:58:31 +0200 Subject: [PATCH] Error should be thrown later when calling super multiple times (#4256) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu --- jerry-core/vm/vm.c | 12 +++++++----- tests/test262-es6-excludelist.xml | 1 - tests/test262-esnext-excludelist.xml | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index d98248c4a..2eb7284eb 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -577,11 +577,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ ecma_property_t *prop_p = ecma_op_get_this_property (frame_ctx_p->lex_env_p); - if (ecma_op_this_binding_is_initialized (prop_p)) - { - completion_value = ecma_raise_reference_error (ECMA_ERR_MSG ("Super constructor may only be called once")); - } - else if (!ecma_is_constructor (func_value)) + if (!ecma_is_constructor (func_value)) { completion_value = ecma_raise_type_error (ECMA_ERR_MSG ("Class extends value is not a constructor.")); } @@ -609,6 +605,12 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } ecma_free_value (proto_value); } + + if (!ECMA_IS_VALUE_ERROR (completion_value) && ecma_op_this_binding_is_initialized (prop_p)) + { + ecma_free_value (completion_value); + completion_value = ecma_raise_reference_error (ECMA_ERR_MSG ("Super constructor may only be called once")); + } } /* Free registers. */ diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index 0c124489f..03e3dc209 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -303,7 +303,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 191ad361d..1e588bb0d 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -4060,7 +4060,6 @@ -