Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions jerry-core/parser/js/js-scanner-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,45 +1237,41 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */

JERRY_ASSERT (SCANNER_LITERAL_POOL_MAY_HAVE_ARGUMENTS (literal_pool_p->status_flags));

if (can_eval)
if (JERRY_UNLIKELY (can_eval))
{
if (prev_literal_pool_p != NULL)
{
prev_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_CAN_EVAL;
}

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);
}
literal_pool_p->status_flags &= (uint16_t) ~SCANNER_LITERAL_POOL_CAN_EVAL;
}

literal_pool_p->status_flags &= (uint16_t) ~SCANNER_LITERAL_POOL_CAN_EVAL;

parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);

while (true)
else
{
literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator);
parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);

if (literal_p == NULL)
while (true)
{
return;
}
literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator);

if (can_eval || (literal_p->type & SCANNER_LITERAL_EARLY_CREATE))
{
literal_p->type |= SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_EARLY_CREATE;
}
if (literal_p == NULL)
{
return;
}

uint8_t type = literal_p->type;
const uint8_t mask =
(SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG);
if (can_eval || (literal_p->type & SCANNER_LITERAL_EARLY_CREATE))
{
literal_p->type |= SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_EARLY_CREATE;
}

if ((type & mask) != SCANNER_LITERAL_IS_ARG)
{
break;
uint8_t type = literal_p->type;
const uint8_t mask =
(SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG);

if ((type & mask) != SCANNER_LITERAL_IS_ARG)
{
break;
}
}
}

Expand Down Expand Up @@ -1309,10 +1305,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */

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));
has_arguments = false;
}

if (type & (SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG))
Expand Down Expand Up @@ -1371,6 +1364,12 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
}
}

if (has_arguments)
{
/* Force the lexically stored arguments object creation */
new_literal_pool_p->status_flags |= (SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS | SCANNER_LITERAL_POOL_NO_ARGUMENTS);
}

new_literal_pool_p->prev_p = prev_literal_pool_p;

parser_list_free (&literal_pool_p->literal_pool);
Expand Down
5 changes: 5 additions & 0 deletions tests/jerry/es.next/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,8 @@ function f22 (arguments, [a = arguments]) {
assert(arguments === 3.1);
}
f22(3.1, []);

function f23(arguments, eval = () => eval()) {
assert(arguments === undefined);
}
f23(undefined);