Improve new.target handling in case of eval calls (#3517)

Only direct eval calls propagate the "new.target" information.
In any other eval cases the "new.target" invocation is a syntax error.

Added test cases also.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Péter Gál
2020-01-21 18:01:35 +01:00
committed by Robert Fancsik
parent 05b4bda927
commit 608bc9e5ff
3 changed files with 29 additions and 3 deletions
@@ -1138,7 +1138,8 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
{
#if ENABLED (JERRY_ES2015)
ecma_object_t *old_new_target = JERRY_CONTEXT (current_new_target);
if (JERRY_LIKELY (!ecma_get_object_is_builtin (func_obj_p)))
/* If the current function is not a direct eval call the "new.target" must be updated. */
if ((JERRY_CONTEXT (status_flags) & ECMA_STATUS_DIRECT_EVAL) == 0)
{
JERRY_CONTEXT (current_new_target) = NULL;
}