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
10 changes: 10 additions & 0 deletions jerry-core/parser/js/js-scanner-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the argument checking as a for loop here since the while (true) loop might also exit. This case is rare, so an extra loop should not cost much.

}
}
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect style.

& ~(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;
Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions tests/jerry/es.next/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,21 @@ function f19(e = (v) => eval(v))
assert(arguments === -12.5)
}
f19(undefined, "A");

function f20 (arguments, a = eval('arguments')) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f20(3.1);

function f21 (arguments, a = arguments) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f21(3.1);

function f22 (arguments, [a = arguments]) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f22(3.1, []);