Skip to content
Open
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
3 changes: 2 additions & 1 deletion Libraries/LibJS/Rust/src/scope_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ impl ScopeCollector {
let index = self.current.expect("close_scope with no current scope");

if let Some(parent_index) = self.records[index].parent
&& !self.records[index].has_function_parameters
&& (self.records[index].scope_type != ScopeType::Function
|| self.records[index].is_arrow_function)
{
let c = &self.records[index];
let arguments = c.contains_access_to_arguments_object_in_non_strict_mode;
Expand Down
8 changes: 8 additions & 0 deletions Tests/LibJS/Runtime/arguments-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ test("basic arguments object", () => {
expect(bar("hello", "friends", ":^)")).toBe("friends");
expect(bar("hello")).toBe(undefined);
});

test("arrow function access keeps mapped parameter bindings in the environment", () => {
function outer(value) {
return (() => arguments[0])();
}

expect(outer(42)).toBe(42);
Comment on lines +19 to +22
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

This regression test validates the crash fix, but it doesn't actually assert mapped-arguments behavior (an unmapped arguments object would still return the original value). To ensure the outer parameter binding is preserved and mapped, add an assertion that mutating arguments[0] (or the parameter) inside the arrow is reflected in the other binding.

Suggested change
return (() => arguments[0])();
}
expect(outer(42)).toBe(42);
return (() => {
expect(arguments[0]).toBe(value);
arguments[0] = 84;
return value;
})();
}
expect(outer(42)).toBe(84);

Copilot uses AI. Check for mistakes.
});
Loading