Skip to content

Commit 7e2cf8d

Browse files
authored
feat(react-compiler): tighten core validation parity for upstream fixtures (#11734)
## Summary This PR continues the React Compiler SWC core-only parity work in `crates/swc_ecma_react_compiler`. ### What changed - Aligned `compile_fn` pipeline ordering with upstream behavior in [`program.rs`](crates/swc_ecma_react_compiler/src/entrypoint/program.rs): - Run `validate_locals_not_reassigned_after_render` unconditionally after `infer_mutation_aliasing_ranges`. - Replaced no-op validator with implementation: - `validate_no_capitalized_calls` - Added a conservative but working implementation for: - `validate_context_variable_lvalues` - Reduced false positives and improved message parity in: - `validate_locals_not_reassigned_after_render` - (focuses on async reassignment path in this round) - Improved hooks validation behavior: - dynamic-hook call diagnostics - optional-call handling - assignment-based hook alias tracking ## Fixture metrics Using: ```bash REACT_COMPILER_FIXTURE_CONTINUE_ON_FAIL=1 REACT_COMPILER_FIXTURE_ALLOW_FAILURE=1 cargo test -p swc_ecma_react_compiler fixture_cases_upstream -- --nocapture ``` - Prior baseline (from previous parity round): - `mismatch=844` - `missing_diag=192` - `missing_fragment=34` - Current (this branch): - `mismatch=842` - `missing_diag=167` - `missing_fragment=31` - total failed fixtures: `1040` Top mismatch clusters currently remain: - `propagate-scope-deps-hir-fork/* = 47` - `preserve-memo-validation/* = 40` - `ssa-* (top-level) = 35` ## Verification - `git submodule update --init --recursive` - `cargo check -p swc_ecma_react_compiler` - `cargo test -p swc_ecma_react_compiler fixture_cases_local -- --nocapture` - `cargo test -p swc_ecma_react_compiler fixture_cases_upstream_phase1 -- --nocapture` - `cargo fmt --all` - `cargo clippy --all --all-targets -- -D warnings` Notes: - `cargo test -p swc_ecma_react_compiler` still fails on expected upstream mismatch fixtures (non-continue mode).
1 parent abaee54 commit 7e2cf8d

File tree

5 files changed

+657
-45
lines changed

5 files changed

+657
-45
lines changed

crates/swc_ecma_react_compiler/src/entrypoint/program.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ pub fn compile_fn(
277277
optimization::prune_maybe_throws(&mut hir);
278278

279279
inference::infer_mutation_aliasing_ranges(&mut hir);
280-
if opts.environment.assert_valid_mutable_ranges {
281-
validation::validate_locals_not_reassigned_after_render(&hir)?;
282-
}
280+
// Upstream runs this validation unconditionally and reserves
281+
// `assert_valid_mutable_ranges` for additional internal checks.
282+
validation::validate_locals_not_reassigned_after_render(&hir)?;
283283

284284
if opts.environment.validate_ref_access_during_render {
285285
validation::validate_no_ref_access_in_render(&hir)?;

0 commit comments

Comments
 (0)