fix(macros): diagnose tuple-pattern @State/@Persisted; letToVar FixIt; pin untested guards#261
Merged
Conversation
…; pin untested guards A tuple or wildcard binding (@State var (a, b) = (0, 1)) hit the peer macro's entry guard and returned [] with no diagnostic — and the compiler never runs the accessor role for those patterns, so the property compiled as plain, non-reactive storage: no cell, no HMR snapshot, no persistence. Both peers now diagnose the pattern first (the @MutationState/@ReducerState guard, ported), because every later 'accessor path diagnosed it' bail is silent for these shapes. Also: @persisted's requiresVar gains the letToVar FixIt its three sibling macros already attach; @query's member names list drops for the exact (matching @mutation); prefixMustBeLiteral — the one plugin diagnostic with zero assertions — gets goldens for a variable and an interpolated prefix. New PeerGuardDirectTests invoke the peer expansions directly on parsed syntax: assertMacroExpansion cannot reach these guards (it injects its own multi-binding error the real compiler never emits, and tuple shapes bypass the harness's accessor run). Whole-package swift test: 1904 green — MacroConsumerChecks host-compile the tightened @query names list. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📦 Bundle size
✅ Within budget (≤5% growth allowed). Baseline: Swift 6.3, WASM SDK 6.3-RELEASE, measured 2026-06-18. |
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.
Audit backlog B9 (Part-4 Mediums).
@State var (a, b) = (0, 1)hit the peer's entry guard and returned[]with no diagnostic, while the compiler skips the accessor role for those patterns entirely — the property compiled as plain, non-reactive storage. Both@Stateand@Persistedpeers now diagnose the pattern first (ported from@MutationState/@ReducerState).@PersistedrequiresVar now attaches theletToVarFixIt its three siblings have (FixItSpec-asserted).@Querymember names tightened fromnamed(queryKey), arbitrarytonamed(queryKey), named(init)— symmetric with@Mutation, and host-proven by MacroConsumerChecks/integration tests.prefixMustBeLiteral(the only plugin diagnostic with zero assertions) gets goldens for a variable prefix and an interpolated prefix.PeerGuardDirectTests: direct invocation of the peer expansions on parsed syntax — the only vehicle for these guards, sinceassertMacroExpansioninjects its own multi-binding error (which the real compiler never emits) and never exercises the tuple path.Whole-package
swift test: 1904 tests, 352 suites, green.🤖 Generated with Claude Code