fix(resolution): a same-name re-binding is not a local definition - #1760
fix(resolution): a same-name re-binding is not a local definition#1760danusha2345 wants to merge 3 commits into
Conversation
`const { fetchUser } = useStore.getState()` and `const setZipUri =
useStore((s) => s.setZipUri)` are how a store action reaches its caller;
the local-binding rule read both as definitions and dropped the
cross-file edge the store-action resolution exists to hold
(object-literal-methods, ui-steps-api). A declaration whose pattern or
initializer names the same member is a re-binding of something defined
elsewhere: the graph's symbol is what the bare call means.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit afa69fc)
`const now = opts.now || Date.now` is a local binding after all: on a Kotlin + JS app the wider "initializer mentions the name" exemption sent 24 `now()` calls onto a Kotlin test's `private val now`. A re-binding is a destructuring pattern or an arrow that picks the member off its own parameter (`useStore((s) => s.setZipUri)`); `() => Date.now()` is not one. The `options.now` fixture is back in the test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Second commit, |
Replaces the fork-local carve-out with the version in upstream PR colbymchenry#1760, which fixes the same colbymchenry#1759 regression. Adopting it now means the merge is clean when colbymchenry#1760 lands instead of conflicting in name-matcher.ts. The two differ in approach. The carve-out kept destructuring in declRe and excluded `.getState()` / `get()` initialisers by name; colbymchenry#1760 drops the destructuring alternation from declRe entirely, so a destructured binding is never a candidate, and matches a selector by backreference — the arrow's body must read the member off its OWN parameter. That also reclassifies `const now = opts.now || (() => Date.now())`, which the carve-out kept shadowing. bare-call-no-method, object-literal-methods and ui-steps-api: 25 passed, including colbymchenry#1760's new store-selector test, carried over with it.
|
Merged current |
Follow-up to #1759 (the landing of #1735). Fixes a regression that is on
mainnow:object-literal-methods.test.tsandui-steps-api.test.tsfail atcd4e65b(3 tests), because the local-binding rule reads a store-action re-binding as a local definition.What
const { fetchUser } = useStore.getState()andconst setZipUri = useStore((s) => s.setZipUri)are how a store action reaches its caller, and the store-action resolution follows exactly those shapes. Rule 2 of #1759 ("a name the file binds itself has no cross-file candidate") counted both as definitions and droppedloginFlow → fetchUserandhandleZipComplete → setZipUri— edges the graph is built to hold.A declaration whose pattern or initializer names the same member is a re-binding of something defined elsewhere, not a definition: the graph's symbol is what the bare call means.
isLocallyBoundJsNamenow skips a destructuring pattern altogether and a plainconst x = …whose initializer mentionsx(s.setZipUri,options.now).const transform = makeTransform(), a parameter, afunction/classdeclaration and an arrow bound to a fresh name still shadow.The fixture's
const now = options.now || (() => Date.now())case is dropped from the "locally bound" test: by this rule it is a re-binding, and the graph's cross-filenowis what it meant before #1759 too. The new test pins the store shapes.Measured
vitejs/vite
8492422, wasm arm, edge rows keyed withresolvedBy. Onmainat2f1a99d(pre-#1759) the two rules with this fix: LOST 709 / GAINED 137 — the removals are the #1714 shape (import(…)→runner.ts::import264,resolve(…)/transform(…)→PluginContainer217, a fixture'stest91, …); 86 of the gains areresolvebound byimport { resolve } from 'node:path'landing on a nestedconst resolveinconfig.ts, which #1715's bare-import guard declines. Stacked on #1715: LOST 515 / GAINED 56 (41 arelog(…)moving ontoevent.d.ts's declared global).Tests
bare-call-no-method6/6 (one new: a hook selector and agetState()destructure keep their edges),object-literal-methodsandui-steps-apipass again,resolution198/198,cross-file-visibility,frameworks-integration;tscclean. Full suite on Linux: only the viewer-lesscodegraph ui/ui-packagefiles fail here, same as onmain.🤖 Generated with Claude Code