Skip to content

Fix(Compiler): prevent PropertyLoad from aliasing parent object as ref#422

Closed
everettbu wants to merge 3 commits into
mainfrom
main-35624
Closed

Fix(Compiler): prevent PropertyLoad from aliasing parent object as ref#422
everettbu wants to merge 3 commits into
mainfrom
main-35624

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35624
Original author: SHIVIKA330


Summary

How did you test this change?

@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

Fixed a bug in the React compiler's ref validation where PropertyLoad operations were incorrectly aliased to their parent object in the temporaries sidemap. This caused the validator to misidentify ref accesses through property loads (e.g., object.foo where foo is a function that accesses a ref), resulting in incorrect error messages.

The fix removes the problematic PropertyLoad case from collectTemporariesSidemap, preventing property loads from being aliased to their parent objects. This allows the validator to correctly track when property-loaded functions access refs during render.

The remaining changes are formatting updates (adding spaces in object literal type definitions) and corresponding test snapshot updates that reflect the corrected validation behavior.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix addresses a specific aliasing bug in the compiler's ref validation logic by removing problematic code that caused incorrect error messages. The change is well-targeted and includes comprehensive test snapshot updates (119 files) that validate the corrected behavior. The formatting changes are consistent and improve code readability without affecting functionality.
  • No files require special attention

Important Files Changed

Filename Overview
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts Removed PropertyLoad aliasing logic that incorrectly treated property loads as their parent object, plus formatting cleanup
compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/error.invalid-access-ref-in-render-mutate-object-with-ref-function.expect.md Test snapshot updated to reflect corrected error message for ref access via property load
compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/new-mutability/mutate-after-useeffect-ref-access.expect.md Test snapshot updated with corrected line/column positions after formatting changes

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Jan 26, 2026
@everettbu
everettbu deleted the main-35624 branch January 26, 2026 05:23
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