Improve ecma_reject to give more detailed error messages (#4565)

Note: TypedArray.[[DefineOwnProperty]] has been slightly reworked (without semantical changes) for better error messages.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2021-02-24 09:36:55 +01:00
committed by GitHub
parent 1623c8db1e
commit f0f2a28109
8 changed files with 174 additions and 167 deletions
@@ -31,25 +31,6 @@
* @{
*/
/**
* Reject sequence
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_reject (bool is_throw) /**< Throw flag */
{
if (is_throw)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type"));
}
else
{
return ECMA_VALUE_FALSE;
}
} /* ecma_reject */
/**
* 'Object' object creation operation with no arguments.
*
@@ -386,7 +367,9 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!ecma_op_ordinary_object_is_extensible (object_p))
{
/* 2. */
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
return ECMA_REJECT_WITH_FORMAT (property_desc_p->flags & ECMA_PROP_IS_THROW,
"Cannot define property '%', object is not extensible",
ecma_make_prop_name_value (property_name_p));
}
/* 4. */
@@ -436,7 +419,8 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{
ecma_free_value (ext_property_ref.property_ref.virtual_value);
}
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags);
}
if (ECMA_PROPERTY_IS_VIRTUAL (current_prop))
@@ -451,7 +435,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
&& !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.virtual_value)))
{
result = ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
result = ecma_raise_property_redefinition (property_name_p, property_desc_p->flags);
}
ecma_free_value (ext_property_ref.property_ref.virtual_value);
@@ -477,7 +461,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
&& !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.value_p->value))))
{
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags);
}
}
else
@@ -498,7 +482,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
&& prop_desc_setter_cp != get_set_pair_p->setter_cp))
{
/* i., ii. */
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags);
}
}
}
@@ -509,7 +493,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!is_current_configurable)
{
/* a. */
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags);
}
ecma_property_value_t *value_p = ext_property_ref.property_ref.value_p;