Skip to content

Conversation

@karankumbhare90
Copy link

Summary:

  • Reproduced a false-positive where destructuring a hook-named identifier from an object and then calling it is flagged:
    const { useValue } = hooks;
    useValue(); // should be allowed

  • Root cause: The compiler treated hook-like names as values too eagerly without confirming how the binding is used.

  • Fix: For each Place in the HIR, compute whether it is only used as the callee of calls. If so, skip the "Hooks may not be referenced as normal values" error for KnownHook kinds. Otherwise preserve existing behavior.

Repro (Playground):
https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABFMBANQEMAbKBXAXlwAoBKGgPn0IFkEBbCOxl3ABYATABpcAbQC6DANwAdDOix4AFhAgBrMDVzA2xcpVwBfBRkXKcuAGIkAlmR21+1VsEW5cVvPoKGKKmRcKhNddS0wcy8fXAA3Iypaf1JAxmjcGARsWAxcAB4wAAcSDGZgBMCTfIB6YtLmRRNFS0xrAHUIGG1dV3dPbzbfA1TKYLjTcI1tDNjK41o49IGsnJg8wpKyisTquq3GjGaMEFE0TAAzewBzFBB7LiKuvGwATyKqfQAFCmv7DAA8kVsPY2pMLjAIFxcAByABGJDhCDIAFoir9-iisiQ4NgUehHo4EDAagATew4GHmRR0DxHXBgEggsBXBA6H5QP6A4GgrByU7gdQAdwAkhhsMSMOQwCgLtKECYgA

Notes:

  • This change is conservative: it only suppresses the error when every usage of the Place is a direct call callee.
  • I couldn't run the full repo tests locally due to Windows scripting/tooling differences; CI will run tests in the PR. I added a local code change and explanation; happy to add fixture tests if maintainers prefer and can advise where they want them.
@meta-cla
Copy link

meta-cla bot commented Dec 9, 2025

Hi @karankumbhare90!

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!

@karankumbhare90 karankumbhare90 force-pushed the fix/compiler-allow-destructure-hook-calls branch from 033df76 to e1ba647 Compare December 9, 2025 09:10
@meta-cla meta-cla bot added the CLA Signed label Dec 9, 2025
@josephsavona
Copy link
Member

Closing as this does not meet baseline criteria for PRs: no tests, no alignment with the team that the fix is the correct approach, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants