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:
committed by
Robert Fancsik
parent
05b4bda927
commit
608bc9e5ff
@@ -100,8 +100,9 @@ ecma_op_eval_chars_buffer (const lit_utf8_byte_t *code_p, /**< code characters b
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ECMA_CLEAR_SUPER_EVAL_PARSER_OPTS ();
|
||||
|
||||
/* If an eval is used inside the function the info should be propagated. */
|
||||
if (JERRY_CONTEXT (current_new_target) != JERRY_CONTEXT_INVALID_NEW_TARGET)
|
||||
/* If a direct eval is used inside the function the info should be propagated. */
|
||||
if (JERRY_CONTEXT (current_new_target) != JERRY_CONTEXT_INVALID_NEW_TARGET
|
||||
&& (JERRY_CONTEXT (status_flags) & ECMA_STATUS_DIRECT_EVAL))
|
||||
{
|
||||
parse_opts |= ECMA_PARSE_FUNCTION;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user