Repository navigation
fix(core): treat {@const} and {let}/{const} declaration tags as shadowing bindings - #301
Merged
Merged
Conversation
📝 WalkthroughWalkthroughFragment-level ChangesFragment const shadowing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
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
Follow-up flagged by the final review of #285:
scopeIntroducedNamesdid not treat template declaration tags as scope-introducing, so a write to a template-local alias was misattributed to a same-named top-level$statebinding. Covers{@const ...}(ConstTag) and the newer{let ...}/{const ...}declaration tags (DeclarationTag, svelte.dev/docs/svelte/declaration-tags — AST shape verified against svelte 5.56). Verified false positive before this fix:correctness/nonreactive-builtin-stateflagged the outertags, and the same misattribution suppressedcorrectness/unmutated-state'sconstableStates.Change
One addition to the shared
scopeIntroducedNameshelper: aFragment's ownConstTag/DeclarationTagdeclarations now shadow the whole fragment (same over-conservative whole-scope model as a block'slet; both node types carry the samedeclaration.declarationsshape, so one branch covers all three tags). A write to one of these template-locals — possible for{let}— is still not a write to the outer binding, so the fix is strictly precision-improving for every consumer of the helper (all component-analysis collectors) at once.Testing
{@const}/{let}/{const}+ constableStates for{@const}mutation and{let}reassignment), each verified to fail without the fix and pass with it🤖 Generated with Claude Code