[compiler] Allow ref initialization with sentinel values#36453
[compiler] Allow ref initialization with sentinel values#36453trandaiviethung2001 wants to merge 1 commit into
Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
Fixes #30782.
Allow the ref access validator to recognize lazy initialization patterns that use a module-level sentinel value passed to
useRef, for exampleuseRef(UNINITIALIZED)guarded byref.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 buildcorepack yarn workspace snap run snap --pattern allow-ref-initialization-symbol --synccorepack yarn workspace snap run snap --pattern allow-ref-initialization --synccorepack yarn workspace snap run snap --pattern error.ref-initialization-arbitrary --synccorepack yarn workspace snap run snap --pattern error.ref-initialization-other --synccorepack yarn workspace snap run snap --pattern error.ref-initialization-linear --sync