dillon1000/react

Commit

Support destructuring assignment of context variables

Fixes T178003134. Previously we did not check whether values reassigned during a 
destructuring assignment were context variables. This would either miscompile, 
or as of my fix earlier in #2579, would fail validation. Specifically, this 
happened on AssignmentEpression with an object/array pattern lvalue, where the 
pattern contained an identifier that is a context variable. 

This is now fixed: we track whether the outermost assignment is a normal 
assignment or destructuring, and force destructuring to a temporary whenever the 
identifier is a context variable. We apply the same logic to variable 
declarations that are destructuring to a context variable.
Browse files
Changed paths11 files
First-parent comparison
M compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-assignment-to-context-var.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-assignment-to-context-var.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-declaration-to-context-var.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-declaration-to-context-var.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-assignment-to-context-var.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-assignment-to-context-var.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-declaration-to-context-var.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-declaration-to-context-var.js AddedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo.destructure-assignment-to-context-var.expect.md DeletedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo.destructure-assignment-to-context-var.js Deleted
Patch

Files changed

Rendering syntax-highlighted changes…