Skip to content

[compiler] Allow ref initialization with sentinel values#36453

Open
trandaiviethung2001 wants to merge 1 commit into
facebook:mainfrom
trandaiviethung2001:fix-ref-sentinel-initialization
Open

[compiler] Allow ref initialization with sentinel values#36453
trandaiviethung2001 wants to merge 1 commit into
facebook:mainfrom
trandaiviethung2001:fix-ref-sentinel-initialization

Conversation

@trandaiviethung2001
Copy link
Copy Markdown

@trandaiviethung2001 trandaiviethung2001 commented May 12, 2026

Summary

Fixes #30782.

Allow the ref access validator to recognize lazy initialization patterns that use a module-level sentinel value passed to useRef, for example useRef(UNINITIALIZED) guarded by ref.current === UNINITIALIZED.

The validator now tracks a stable key for non-local bindings so repeated LoadGlobal(module) reads of the same sentinel compare as the same initial value. It preserves the existing nullish initialization behavior and keeps non-null arbitrary initialization patterns rejected.

How did you test this change?

  • corepack yarn workspace snap run build
  • corepack yarn workspace snap run snap --pattern allow-ref-initialization-symbol --sync
  • corepack yarn workspace snap run snap --pattern allow-ref-initialization --sync
  • corepack yarn workspace snap run snap --pattern error.ref-initialization-arbitrary --sync
  • corepack yarn workspace snap run snap --pattern error.ref-initialization-other --sync
  • corepack yarn workspace snap run snap --pattern error.ref-initialization-linear --sync

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 12, 2026

Hi @trandaiviethung2001!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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.

[Compiler Bug]: eslint-plugin-react-compiler errors when updating initialization of ref.current

2 participants