Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(react-compiler): preserve outer lexical captures in outlined functions - #26589

Open
dexhunter wants to merge 2 commits into
oxc-project:mainfrom
dexhunter:fix/preserve-react-outlined-closure-scope
Open

fix(react-compiler): preserve outer lexical captures in outlined functions#26589
dexhunter wants to merge 2 commits into
oxc-project:mainfrom
dexhunter:fix/preserve-react-outlined-closure-scope

Conversation

@dexhunter

Copy link
Copy Markdown

Fixes #26519.

When function outlining is enabled, a callback returned by a factory can be moved to module scope even though it reads the factory's options. The generated application then raises ReferenceError: options is not defined before reaching CHART_READY.

This change tracks references outside the outlined function's lexical scope and keeps the affected callback inline when outlining would move it beyond the factory's scope. Safe module/global cases and function-declaration outlining remain available.

Validation:

  • On the current base, the enabled browser arm reproduces the options is not defined failure while the disabled arm reaches CHART_READY.
  • On the candidate, both enabled and disabled browser arms exit successfully, return HTTP 200, reach CHART_READY, and report no page errors. The frozen fixture files remain unchanged.
  • The focused transform suite passes 30 tests with 0 failures. The full Rust test stage passes 4,874 tests with 0 failures and 162 ignored.
  • The repository's required readiness checks pass on the clean candidate, including formatting, lint generation, workspace checks, documentation, and AST generation. The optional cargo shear check was unavailable and is not claimed as run.

AI tools were used for implementation and evaluation preparation, with Luna authoring the change and Astra coordinating the evaluation. The code and results were separately reviewed against the repository source and validation receipts.

This is a correctness fix; no performance improvement is claimed.

Evaluation trajectory

@dexhunter
dexhunter requested a review from Boshen as a code owner September 12, 2026 23:07
@camc314 camc314 added the A-react-compiler Area - React Compiler label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-react-compiler Area - React Compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React Compiler breaks outlined closure

2 participants