Skip to content

JS: Fix flatMap thisArg flowing to the callback index - #22844

Merged
asgerf merged 1 commit into
github:mainfrom
ku-plrg:js/array-flatmap-thisarg
Oct 20, 2026
Merged

asgerf merged 1 commit into
github:mainfrom
ku-plrg:js/array-flatmap-thisarg

Conversation

@stonechoe

Copy link
Copy Markdown
Contributor

The Array#flatMap summary sends thisArg to the wrong callback parameter. It sends thisArg to the index parameter (Parameter[1]). The correct target is the this value of the callback (Parameter[this]).

The summaries for map, filter, find, every and some already use Parameter[this]. This change makes flatMap do the same.

[0].flatMap(function (x, i) {
  sink(this); // Before: no flow. After: flow.
  sink(i);    // Before: flow. After: no flow.
  return [];
}, source());

Specification: Array.prototype.flatMap

@stonechoe
stonechoe requested a review from a team as a code owner October 20, 2026 06:36
Copilot AI max review requested due to automatic review settings October 20, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@asgerf

asgerf commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR! Looks good to me.

@asgerf
asgerf merged commit ef6059a into github:main Oct 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants