Fix ecma_op_get_value_lex_env_base for let/const declarations (#3311)

This patch fixes #3306.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-11-14 13:52:12 +01:00
committed by Dániel Bátyai
parent 213544ae47
commit 204de302aa
2 changed files with 32 additions and 1 deletions
@@ -61,7 +61,17 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
if (property_p != NULL)
{
*ref_base_lex_env_p = lex_env_p;
return ecma_copy_value (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
#if ENABLED (JERRY_ES2015)
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG ("Variables declared by let/const must be"
" initialized before reading their value."));
}
#endif /* ENABLED (JERRY_ES2015) */
return ecma_fast_copy_value (property_value_p->value);
}
break;
}