Skip to content

fix: array filter/map/forEach support index as second callback param#319

Merged
cs01 merged 2 commits intomainfrom
fix-array-callback-index
Mar 13, 2026
Merged

fix: array filter/map/forEach support index as second callback param#319
cs01 merged 2 commits intomainfrom
fix-array-callback-index

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 13, 2026

Summary

  • Array filter, map, and forEach now correctly pass the loop index as the second callback parameter when the callback declares two parameters (e.g., (val, idx) => ...)
  • Fixes native compiler crash ("array index out of bounds") when callbacks use the index parameter, by providing proper type hints via setExpectedCallbackParamTypes for both params
  • Works for both numeric and string arrays

Test plan

  • New test fixture arrays/callback-index-param.ts covers filter+index, map+index for both number[] and string[]
  • npm run verify:quick passes (all tests + Stage 1 self-hosting)

🤖 Generated with Claude Code

@cs01 cs01 merged commit 16fc21d into main Mar 13, 2026
12 checks passed
@cs01 cs01 deleted the fix-array-callback-index branch March 19, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant