## Root cause
The reactive-function backend (`codegen_reactive_function.rs`) only knew
how to turn a plain `BindingIdentifier` lvalue into an
`AssignmentTarget`. Any **destructuring reassignment** to an existing
binding — `[x] = arr`, `({a} = obj)`, `({a} = {a:{}}), ([x] = [[]])` —
hit an unported `invariant_err("Destructuring reassignment targets are
not yet ported to oxc")`.
`codegen_function` deliberately swallows any emission error and falls
back to an **empty body** (a shim from the de-Babel batches). So every
function containing such an assignment silently compiled to `function
f() {}` — params and body both dropped — with **no diagnostic**. This is
a hard miscompile, not a whitespace diff.
## Fix
Port `ox_binding_pattern_to_assignment_target` to recursively reshape
`BindingPattern` → `AssignmentTarget`, since oxc (unlike Babel) models
declaration patterns and assignment targets as distinct node families.
Adds handling for:
- array patterns → `ArrayAssignmentTarget` (elements + holes + rest)
- object patterns → `ObjectAssignmentTarget`, distinguishing shorthand
(`{a}` / `{a = 1}` → `AssignmentTargetPropertyIdentifier`) from keyed
(`{a: b}` → `AssignmentTargetPropertyProperty`)
- rest elements (`...x`)
- nested patterns and defaults (`AssignmentTargetWithDefault`)
Mirrors Babel, which reuses the same pattern nodes as the assignment
LHS.
## Impact
23 corpus snapshots changed — **all move toward the fork golden, none
regress**; 14 now match the fork exactly. Verified old-vs-new token
distance to each fork golden.
Within this batch (`reduce-reactive-deps` /
`propagate-scope-deps-hir-fork`):
- `ssa-renaming-via-destructuring-with-mutation` — was empty function,
now matches the fork exactly.
- `ssa-renaming-ternary-destruction` /
`ssa-renaming-ternary-destruction-with-mutation` — were empty functions,
now compile with **matching dependency sets, cache keys, scope
boundaries, and dead-code elimination**; the only residual is
codegen-only (sequence-expression parenthesisation `([x]=[[]], …)` vs
`(([x]=[[]]), …)` and object-literal whitespace).
Other improved fixtures across the corpus (also previously
empty-bodied): `destructuring`, `destructuring-assignment`,
`destructuring-assignment-array-default`,
`destructure-direct-reassignment`, `destructure-in-branch-ssa`,
`destructuring-object-pattern-within-rest`,
`escape-analysis-destructured-rest-element`,
`call-args-destructuring-assignment`,
`array-pattern-spread-creates-array`, the `nonmutated-spread-*` set,
`repro-reassign-props`, `switch-with-only-default`,
`new-mutability__ssa-renaming-ternary-destruction`.
## Remaining work (out of scope here)
The rest of the batch's diffs are pure codegen and live in
`oxc_codegen`, not the dependency passes:
- sequence-expression parenthesisation of assignment operands (`(a=[],
b)` vs `((a=[]), b)`)
- JSX multi-line wrapping, TS type printing, object/array-literal
whitespace
The two `try-catch-*` fixtures (stray `;`) belong to a sibling
`fix/rc-try-catch` branch and are left untouched.
## Summary
`oxc_react_compiler` had no committed test over the upstream React
Compiler fixture corpus — the fixtures lived only in the
`oxc-project/forked-react-compiler` checkout, exercised out-of-tree.
That gap let real regressions slip past the 15 in-crate integration
tests. This PR closes it.
- **`crates/oxc_react_compiler/fixtures/`** — 1734 fixture *input* files
(`.js`/`.ts`/`.tsx`/`.jsx`/`.mjs`), copied from the fork's
`babel-plugin-react-compiler/src/__tests__/fixtures/compiler` tree with
subdirectories preserved. Flow fixtures (the `@flow`-pragma ones) are
excluded — oxc has no Flow parser. The upstream `.expect.md` goldens are
also not copied; insta is the golden here.
- **`crates/oxc_react_compiler/tests/snapshot.rs`** — an `insta::glob!`
test that, per fixture, derives `PluginOptions`/`EnvironmentConfig` from
the first-line `// @directive` pragmas (base `compilationMode=all` /
`panicThreshold=all_errors`, matching the upstream `snap` runner),
parses → builds semantic → runs `transform`, and snapshots the compiled
output plus diagnostics. Unrecognised directives are ignored, as
upstream does; camelCase flag directives map to `EnvironmentConfig`
fields via `convert_case`.
- **`crates/oxc_react_compiler/tests/snapshots/`** — 1734 committed
`.snap` goldens (oxc's own output).
- **`.typos.toml`** — excludes the fixtures dir (the upstream fixtures
contain intentional typos; `**/*.snap` was already excluded).
These snapshots are oxc's own golden output, so `cargo test` (and CI)
now catches any change in compiler behaviour across the corpus.
Regenerate after an intended change with `cargo insta accept`.
## Verification
- `cargo test -p oxc_react_compiler` passes — the 1734-fixture snapshot
test plus the existing 15 integration tests; also green under
`--all-features` (matches the cross-target CI job).
- clippy `-D warnings`, `cargo fmt`, and `typos` clean.
- No fixture panics; 1336 compiled / 398 unchanged / 335 with
diagnostics.
- The `error.*` fixtures capture the exact diagnostics — including the
"Cannot reassign variable after render" error that a recent scoping
change had silently suppressed, confirming the suite catches real
regressions.
---
AI usage disclosure: authored with Claude Code and reviewed before
submission.
🤖 Generated with [Claude Code](https://claude.com/claude-code)