dillon1000/react

Commit

[compiler] Fix for false positive mutation of destructured spread object (#33786)

When destructuring, spread creates a new mutable object that _captures_
part of the original rvalue. This new value is safe to modify.

When making this change I realized that we weren't inferring array
pattern spread as creating an array (in type inference) so I also added
that here.
Browse files
Changed paths8 files
First-parent comparison
M compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts ModifiedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-pattern-spread-creates-array.expect.md AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/array-pattern-spread-creates-array.js AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-local-mutation-of-new-object-from-destructured-prop.expect.md AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-local-mutation-of-new-object-from-destructured-prop.js AddedM compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…