Skip to content

[compiler] Fix false positive for local mutation in filter callbacks#36269

Open
soloclz wants to merge 1 commit intofacebook:mainfrom
soloclz:fix/react-compiler-filter-local-mutation-upstream
Open

[compiler] Fix false positive for local mutation in filter callbacks#36269
soloclz wants to merge 1 commit intofacebook:mainfrom
soloclz:fix/react-compiler-filter-local-mutation-upstream

Conversation

@soloclz
Copy link
Copy Markdown

@soloclz soloclz commented Apr 14, 2026

Summary

This narrows the fix for ValidateLocalsNotReassignedAfterRender to the behavior that actually resolves the false positive.

The validation now gives PropertyLoad its own non-propagating case, which stops reassignment metadata from flowing from values like someItems into derived property loads like someItems.length. That is enough to avoid incorrectly treating synchronous render-time array callbacks such as filter and map as post-render escapes.

This PR also keeps the regression coverage in the TypeScript eslint-plugin-react-hooks tests for the filter and map repros, with forEach left in place as an adjacent non-regression case.

Related to #31569

How did you test this change?

  • yarn workspace babel-plugin-react-compiler build
  • yarn workspace babel-plugin-react-compiler lint src/Validation/ValidateLocalsNotReassignedAfterRender.ts
  • node ./scripts/jest/jest-cli.js --runTestsByPath packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts --runInBand

@meta-cla meta-cla bot added the CLA Signed label Apr 14, 2026
@alisa-xh

This comment was marked as spam.

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.

2 participants