Prevent arguments object creation if 'arguments' function argument is present (#4849)

This patch fixes #4847.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
Robert Fancsik
2021-12-07 14:05:48 +01:00
committed by GitHub
parent f8faf574b6
commit 18dd9aa75a
2 changed files with 28 additions and 0 deletions
+10
View File
@@ -1246,6 +1246,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
if (has_arguments)
{
/* Force the lexically stored arguments object creation */
literal_pool_p->status_flags |= (SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS | SCANNER_LITERAL_POOL_NO_ARGUMENTS);
}
}
@@ -1306,6 +1307,14 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
literal_p->type = type;
}
if (has_arguments && scanner_literal_is_arguments (literal_p))
{
/* 'arguments' function argument existence should prevent the arguments object construction */
new_literal_pool_p->status_flags =
(uint16_t) (new_literal_pool_p->status_flags
& ~(SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS | SCANNER_LITERAL_POOL_NO_ARGUMENTS));
}
if (type & (SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG))
{
has_destructured_arg = true;
@@ -1328,6 +1337,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
}
else if (has_arguments && scanner_literal_is_arguments (literal_p))
{
/* Arguments object is directly referenced from the function arguments */
new_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS;
if (type & SCANNER_LITERAL_NO_REG)