fix(core): tracking of bindings and value references#9886
Conversation
🦋 Changeset detectedLatest commit: 97cdc63 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dyc3
left a comment
There was a problem hiding this comment.
Unfortunate losing the hashmap
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughRefactors embedded binding and value-reference storage from per-snippet hash maps to nested vectors of (TextRange, TokenText) tuples across analyzer and service crates. Updates APIs and tests to use the new shape, removes FxHashMap imports, and expands Svelte snippet default-parameter handling and tests to fix intermittent false positives for Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/clever-wombats-move.md:
- Line 5: Line 5 contains typos and awkward phrasing—change "occassionally" to
"occasionally", change "reference weren't" to "references weren't" (or rephrase
to "references weren't being tracked"), and trim repetition by rewriting the
sentence into a concise 1–2 sentence release note that mentions the root cause
and affected lint rules (e.g., "Fix occasional failure to track some bindings
and references that caused false positives in noUnusedVariables and
noUndeclaredVariables for Svelte, Vue, and Astro files.").
In
`@crates/biome_service/src/workspace/document/services/embedded_value_references.rs`:
- Around line 37-39: Add a collision regression test that constructs two
distinct snippets whose local TextRange values are identical (e.g., ranges for
"Foo;" and "Bar;") and calls register_reference for each (using TokenText for
the snippet text), then assert both entries survive in the storage (the
references Vec or the public accessor) so the previous FxHashMap-collision bug
can't reoccur; specifically, create a test that uses register_reference and
verifies that both TokenText values are present for the same TextRange rather
than one overwriting the other, and add it as a snapshot/unit test alongside the
other embedded-value-reference tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a001ae29-efea-4cd5-89e0-558c83955679
⛔ Files ignored due to path filters (2)
crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/invalid_svelte_snippet_defaults.svelte.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/valid_svelte_snippet_defaults.svelte.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (8)
.changeset/clever-wombats-move.mdcrates/biome_js_analyze/src/lib.rscrates/biome_js_analyze/src/services/embedded_bindings.rscrates/biome_js_analyze/src/services/embedded_value_references.rscrates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/invalid_svelte_snippet_defaults.sveltecrates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/valid_svelte_snippet_defaults.sveltecrates/biome_service/src/workspace/document/services/embedded_bindings.rscrates/biome_service/src/workspace/document/services/embedded_value_references.rs
c1d0844 to
80e9b2e
Compare
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
This PR fixes two bugs:
FxHashMap, two bindings in two different snippets that had the same range were swallowed into one. I changed the storage intoVec, which keeps the duplicateThe use of AI was limited in finding the issue and creating the code for object/array assignments (rewritten a couple of times).
Test Plan
Added new tests.
The new svelte test is where I encountered the issue.
Docs