The constructor check should return false for arrow and generator functions (#4328)

The previous `ecma_is_constructor` implementation did not checked if the
target function was an arrow or generator function. This resulted in
an incorrect execution for these function types.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
Péter Gál
2020-11-24 12:46:44 +01:00
committed by GitHub
parent cc52282f34
commit 3af3597f2e
5 changed files with 130 additions and 105 deletions
+6 -6
View File
@@ -691,10 +691,10 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
if (frame_ctx_p->byte_code_p[1] == CBC_EXT_SPREAD_NEW)
{
if (!ecma_is_value_object (func_value)
|| !ecma_object_is_constructor (ecma_get_object_from_value (func_value)))
const char *constructor_message_p = ecma_check_constructor (func_value);
if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR)
{
completion_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected a constructor."));
completion_value = ecma_raise_type_error (constructor_message_p);
}
else
{
@@ -879,10 +879,10 @@ opfunc_construct (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
ecma_value_t constructor_value = stack_top_p[-1];
ecma_value_t completion_value;
if (!ecma_is_value_object (constructor_value)
|| !ecma_object_is_constructor (ecma_get_object_from_value (constructor_value)))
const char *constructor_message_p = ecma_check_constructor (constructor_value);
if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR)
{
completion_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected a constructor."));
completion_value = ecma_raise_type_error (constructor_message_p);
}
else
{