Implement throwing const re-assignment error. (#3697)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-04-29 15:50:22 +02:00
committed by GitHub
parent 9e6c44be4f
commit 4b780507e1
14 changed files with 220 additions and 52 deletions
@@ -257,6 +257,12 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
ecma_named_data_property_assign_value (lex_env_p, property_value_p, value);
}
#if ENABLED (JERRY_ES2015)
else if (ecma_is_property_enumerable (*property_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned."));
}
#endif /* ENABLED (JERRY_ES2015) */
else if (is_strict)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set."));
@@ -239,6 +239,12 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
{
ecma_named_data_property_assign_value (lex_env_p, ECMA_PROPERTY_VALUE_PTR (property_p), value);
}
#if ENABLED (JERRY_ES2015)
else if (ecma_is_property_enumerable (*property_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned."));
}
#endif /* ENABLED (JERRY_ES2015) */
else if (is_strict)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set."));