Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Allow mutating refs in callbacks passed to JSX #29733

Merged
merged 4 commits into from
Jun 7, 2024

Commits on Jun 3, 2024

  1. compiler: Add support for ref effects

    [ghstack-poisoned]
    josephsavona committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    55ec34a View commit details
    Browse the repository at this point in the history
  2. Update on "compiler: Add support for ref effects"

    Fixes false positives where we currently disallow mutations of refs from callbacks passed to JSX, if the ref is also passed to jsx. We consider these to be mutations of "frozen" values, but refs are explicitly allowed to have interior mutability.
    
    The fix is to add a new RefMutation variant to FunctionEffect, which we emit whenever a ref is mutated. We disallow this effect type from within a function body, but allow it within function expressions that are passed to useEffect and friends as well as to jsx.
    
    [ghstack-poisoned]
    josephsavona committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    72d8c3b View commit details
    Browse the repository at this point in the history

Commits on Jun 7, 2024

  1. Update on "compiler: Add support for ref effects"

    Fixes false positives where we currently disallow mutations of refs from callbacks passed to JSX, if the ref is also passed to jsx. We consider these to be mutations of "frozen" values, but refs are explicitly allowed to have interior mutability.
    
    The fix is to add a new RefMutation variant to FunctionEffect, which we emit whenever a ref is mutated. We disallow this effect type from within a function body, but allow it within function expressions that are passed to useEffect and friends as well as to jsx.
    
    Fixes #29741
    Fixes #29703
    
    [ghstack-poisoned]
    josephsavona committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    6e5b2bc View commit details
    Browse the repository at this point in the history
  2. Update on "compiler: Add support for ref effects"

    Fixes false positives where we currently disallow mutations of refs from callbacks passed to JSX, if the ref is also passed to jsx. We consider these to be mutations of "frozen" values, but refs are explicitly allowed to have interior mutability. The fix is to always allow (at leat within InferReferenceEffects) for refs to be mutated. This means we completely rely on ValidateNoRefAccessInRender to validate ref access and stop reporting false positives.
    
    [ghstack-poisoned]
    josephsavona committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    2cfa72f View commit details
    Browse the repository at this point in the history