Repository navigation
fix: scope Strong switch arms independently - #1040
Merged
domgan-oai merged 1 commit intoSep 10, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
domgan-oai
marked this pull request as ready for review
September 10, 2026 18:56
27 of 35 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@switcharm in its own function scope, with the case tests in their enclosing scope. This fixes false module/ref diagnostics and missed ref, state getter, setter, and snapshot diagnostics.varreassignment proofs separate across sibling arms, and classify non-static class field initializers as deferred while preserving checks on static fields and computed keys.Why
Addresses the checked Strong mode work in point 2 of #1037. The phase analyzer previously descended into switch arms without creating their scopes, even though the locality walker and emitted arm callbacks already gave each arm its own lifetime.
Changes
JSXSwitchExpressionvisitor and arm-local hoisted-variable scopes.octanepatch changeset.Validation
pnpm format:check(scoped check below passed)pnpm typecheck(scoped check below passed)pnpm test(attempted; unrelated local browser projects failed, so the run was stopped)pnpm exec vitest run --project octane --project octane-prod(991 files, 17,787 passed, 14 expected failures on the rebased head)pnpm typecheck:files packages/octane/src/compiler/strong-mode.js packages/octane/src/compiler/hook-deps.js packages/octane/tests/compiler/strong-mode.test.tspnpm format:files:check packages/octane/src/compiler/strong-mode.js packages/octane/src/compiler/hook-deps.js packages/octane/tests/compiler/strong-mode.test.ts .changeset/strong-switch-arm-scopes.mdpnpm sync(clean)Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes opt-in Strong-mode static analysis and hook binding walks only; emitted code is unchanged in tests, but new per-arm scopes could surface or clear diagnostics in edge cases around template switches and in-render classes.
Overview
Strong mode now analyzes each
@switcharm in its own lexical scope, matching how the compiler already emits separate arm callbacks. Case discriminants and tests stay in the parent scope; arm bodies get per-arm function scopes in both the render-phase analyzer (strong-mode.js) and the reassignment/binding walk used for diagnostics (hook-deps.js).That fixes false positives (e.g. arm-local
constshadowing modulerevision) and false negatives (refs, state getters/setters, and snapshot mutations declared in one arm no longer leak to siblings). Case labels are checked before entering the arm scope so reads like@case revisionstill flag module-state use during render.Instance (non-static) class field initializers are visited in the
deferredexecution phase when a class is defined during render, so initializer reads are not treated as synchronous render work; static fields and methods keep the prior timing (static initializers still run at class definition time).Regression tests cover arm shadowing, sibling isolation, arm-local functions, unchanged client/server codegen under Strong vs ordinary compile, and class field timing. Includes an
octanepatch changeset.Reviewed by Cursor Bugbot for commit d797447. Bugbot is set up for automated code reviews on this repo. Configure here.