Skip to content

fix(js,ts): a receiver declared outside the calling function goes by its declared type - #2811

Merged
colbymchenry merged 1 commit into
mainfrom
claude/issue-2589-outside-root-render
Oct 22, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/issue-2589-outside-root-render

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

Fixes #2589. react-dom's root.render(<Popup />) used to link to the project's one class-component render(), an error boundary's in the reporter's app, in two situations: when root was declared outside the calling function, and when it held what createRoot(el) returned. After this change:

  • A JS/TS receiver the calling function doesn't type is read by its binding in scope at the call.
  • A class component's render() and lifecycle methods are never a by-name guess.

Root cause

matchMethodCall asks inferLocalReceiverType for the receiver's type, and that scan only covers the calling function. It reads nothing from these places:

  • a module's let root: Root | null
  • a let popupRoot: Root in the function around the one rendering
  • an outer function's manager: RunnerManager parameter

So #2169's rule (a type the project doesn't declare is an outside type) never ran, and Strategy 3 handed the call to the only same-language method named render. An untyped const r = createRoot(el) reached the same guess even inside the calling function.

Fix

A receiver's binding in scope (jsBindingAt, jsBindingReading in name-matcher.ts):

  • A per-file brace-scope reader (comments, strings and regex literals blanked) finds the innermost binding of the receiver's name at the call. That can be a const/let/var, a parameter list, a destructuring, a for head, a function/class, a lone or destructured arrow parameter, or a catch clause.
  • A declaration or parameter written with a type, or a declaration whose whole value is a new of a class, types the call. From there the existing typed pipeline applies (imported-type file, outside types, resolveMethodOnType), exactly as for the calling function's own declaration.
  • Two cases say nothing and are left to the existing strategies:
    • An annotated object literal stays its own members': vite's const server: ViteDevServer = { … } is the close it declares, not the interface's.
    • A new of a parameter or variable (new Backend(root)) names no class.
  • A nearer binding of the same name always wins. That covers a parameter, an arrow's or a destructured one, and the calling function's own untyped declaration. Another function's binding holds only in that function.
  • It runs only where the binding may lie outside the calling function: in a function nested in another, or for a name the module scope declares. A call outside any function was already read from the file's start. With that pre-filter, the per-reference cost dropped from about 340 µs to about 80 µs on nitro.

React's own methods (isReactLifecycleMethod): a lifecycle method of a class extending Component/PureComponent (render, componentDidMount, …) is ruled out of Strategy 3's by-name candidates for a receiver other than this/super, the same way a Vue component's own methods are. It also counts as narrowing, so a lone other render isn't then guessed instead. That covers the untyped const r = createRoot(el) and ReactDOM.createRoot(el) shapes.

Calls I made

  • I dropped a broader rule I tried first. It treated any receiver whose value a package from outside the project returned as having no project method. The A/B showed it unlinking correct calls through values a hook hands back, such as const parentContext = useContext(AnalyticsContext) in social-app (AnalyticsContextType::metric) and outline's drag-and-drop manager, so only the React-specific rule covers untyped react-dom roots.
  • Some cases are left as they were:
    • An x.render() on a component instance named after its class (Strategy 2).
    • Classes that extend a project base component rather than Component directly.
    • A declaration inside an anonymous callback that no function node covers, which the existing scan already reads from the file's start.

Validation

  • New test __tests__/js-receiver-binding-scope.test.ts (3 tests): all 3 fail on main and pass on the fix.
    • Every shape in the issue, plus ReactDOM.createRoot / hydrateRoot through the default import, and a .jsx class component.
    • Project types from a module binding, an outer function's declaration and an outer parameter.
    • Shadowing: a typed parameter, an arrow's own, a destructured one, another function's declaration, and a new of a parameter.
  • A/B against main 89cd08f, each arm indexed fresh. "Same target" means the same edge with its confidence raised to 0.9.
repo removed added retargeted same target
jest 15 1 1 19
nitro 7
nuxt 5 4
webdriverio 3 4 1 10
vite 2 4 4 10
social-app 1 7 2
outline 1 2 10
vben 1
memfs 1 1
insomnia 36
t3-turbo, vue3-antdv-admin, pathe, c12
flask, gin (controls) byte-identical dumps
  • Triage of every changed edge:
    • The 35 removals were all wrong guesses. They are calls on values whose binding outside the calling function has a type from outside the project: rolldown's RolldownWatcher, a ViteDevServer parameter, env-runner's RunnerManager, node's Server, ChildProcess and AsyncLocalStorage, NodeJS.WriteStream (jest's outputStream.write going to BufferedConsole::write), playwright's BrowserServer, unstorage's Storage, HTMLElement, a zod schema and Omit<…>. One more is nitro's const root = ReactDOM.createRoot(el); root.render(…), the issue's own shape, which went to an unrelated example's ErrorBoundary::render.
    • The 25 added or retargeted edges were all precise. Examples: memfs's onAbort = () => watcher.close() reaching FsaNodeFsWatcher::close instead of CoreWatcher::close, jest's currentSpec.cancel() reaching Spec::cancel instead of PCancelable::cancel, and webdriverio's server.close() reaching SessionServer::close instead of ViteServer::close. Two of them are vite's new WebSocket(…) in an outer function linking to its vendored ws.d.ts class, which is what the same declaration in the calling function already gets.
    • The 92 same-target changes are module-level singletons like insomnia's const repoFileWatcherRegistry = new RepoFileWatcherRegistry(), now typed rather than guessed.
  • Kernel parity: this is a resolution-only change and no extraction changed, so kernel parity is unaffected.
  • Index time: +1.7% total, as the median of 8 interleaved runs on vite, nuxt, webdriverio and insomnia. That is within this machine's noise: per repo the change ranged from -3.6% to +5.2%, and the last 5 rounds alone came to +2.2%. A resolver profile of insomnia puts the new reading at about 0.4 s of roughly 21 s of resolver time, summed over its workers.
  • Base: the branch sits on main f3fdba2. The A/B baseline was 89cd08f. The four commits in between touch neither TS/JS resolution nor TS/JS extraction: fix(bundle): bundle Node 24.21.0 so Windows commands no longer abort as they exit #2806 bundle, fix(add-lang): check-grammar fails a grammar that crashes or hangs its process #2808 add-lang script, fix(extraction): drop the extractVariables hook, which the core never called #2809 an extractor hook the core never called, and fix(pascal): calls inside nested Delphi routines are indexed, each under its routine #2810 Pascal nested routines.
  • Sync: a CLI sync that retypes a module-level binding, adds an untyped createRoot local and adds a file with a module-level new Store() matches a fresh index.
  • Full suite on this commit (CODEGRAPH_KERNEL_EXPECT=1): 726 test files passed and 6 skipped; 8,664 tests passed and 82 skipped.

🤖 Generated with Claude Code

…its declared type

react-dom's root.render(<X />) linked to the project's one class
component render() when root was declared outside the calling
function, a module's let root: Root | null or a let popupRoot: Root in
the function around the one rendering, or held what createRoot(el)
returned (#2589). The receiver reader scans only the calling function,
so the type that rules a react-dom Root out was never read, and the
call went to the one same-named method by its name.

A TS/JS receiver the calling function doesn't type, in a function
nested in another or one a module-scope variable names, is now read by
its binding in scope at the call. A per-file brace-scope reader finds
the innermost binding of the name: a const/let/var, a parameter, a
destructuring, a for head, a function or class, a lone or destructured
arrow parameter. A declaration or parameter written with a type, or a
const/let/var whose whole value is a new of a class, types the call as
the calling function's own declaration would; an annotated object
literal stays its own members', and a new of a parameter names no
class. A class component's render() and lifecycle methods are never a
by-name guess for a receiver other than this or super, since React
calls them, which also covers an untyped const r = createRoot(el). A
first version that also took any value a package function returned to
have no project method was dropped: it unlinked correct calls through
useContext(...) values in social-app and outline.

Validation: the new test fails 3 of 3 on main 89cd08f and passes on
the fix. A/B against main on 14 TS/JS repos: 35 edges removed,
every one a wrong guess on a value whose type outside the calling
function comes from outside the project (rolldown's watcher, node's
Server and ChildProcess, playwright, unstorage, zod, NodeJS.WriteStream,
HTMLElement) or nitro's ReactDOM.createRoot root; 18 added and
7 retargeted, all precise (memfs's onAbort watcher.close() now
reaches FsaNodeFsWatcher::close, jest's currentSpec.cancel() Spec's);
92 same-target edges typed at 0.9 instead of guessed. The flask and
gin control dumps are byte-identical. Index time, median of 8
interleaved runs on vite, nuxt, webdriverio and insomnia: +1.7% total,
within noise (-3.6 to +5.2% per repo). A CLI sync that retypes a
module binding and adds files matches a fresh index.

Fixes #2589

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit 08478ee into main Oct 22, 2026
@colbymchenry
colbymchenry deleted the claude/issue-2589-outside-root-render branch October 22, 2026 18:11
colbymchenry added a commit that referenced this pull request Oct 22, 2026
… their sections (#2812)

Shopify's theme editor writes a block comment ("IMPORTANT: The contents
of this file are auto-generated...") at the top of every JSON template
and section group it saves. The Liquid extractor read theme JSON with
JSON.parse, which rejects comments and trailing commas, so such a file
linked none of the sections it lists, and in an editor-saved theme most
sections looked unused. All 14 of Shopify/horizon's templates and
section groups carry the comment, so none of them linked. The links a
JSON file did produce all sat at line 1, column 0.

The same report found two more gaps. A layout's
{% sections 'header-group' %} tag, which renders the section group
sections/header-group.json, was never read. And a {% schema %} written
inside {% comment %} or {% raw %} was indexed as the section's own
schema, because only the tag scanner skipped those regions.

Fix:
- Read theme JSON with jsonc-parser's parseTree, which accepts
  comments, and allow trailing commas. Shopify's theme docs say theme
  JSON supports both, and Shopify's theme-check parses it with the same
  options. Any other parse error still links nothing.
- Put each section reference at its "type" value's line and column.
- Read the plural sections tag wherever the singular one is read:
  braced, whitespace-trimmed, or as a line of a {% liquid %} tag. It
  links to sections/<group>.json, and its component is named
  ::sections:<group>, apart from a section of the same name. The
  Shopify theme matcher already keeps any sections/ path inside the
  file's own theme, so a group resolves only there (its doc comment now
  says so).
- Compute the comment and raw regions once per file and share them
  between the tag scanner and the schema extractor. A schema inside one
  is skipped, and the search resumes after the region.

Validation:
- 10 new regression tests in __tests__/extraction.test.ts fail with
  main's extractor and pass with the fix. Re-run on 08478ee: 30 passed
  and 10 failed with main's extractor, 40 passed with the fix. 3
  strictness guards (a missing brace, an unclosed comment, a missing
  comma) pass on both.
- A/B on base 80c3680, each arm built from its own sources with the
  kernel: 8 theme repos (Shopify/dawn, Shopify/horizon,
  Shopify/skeleton-theme, ChumsInc/chums-impulse-dev,
  agencecinq/cinquante-et-un, noclocks/shopify-devstore-theme,
  panoply/syncify, Shopify/theme-tools) and 2 controls (express,
  requests). The controls and skeleton-theme are byte-identical, and no
  node or edge is removed anywhere. All 299 changed reference edges
  were checked against the source text: 299 right, 0 wrong. 197 are new
  links (horizon 25, chums-impulse-dev 138, cinquante-et-un 11,
  shopify-devstore-theme 16, dawn 2, syncify 2, theme-tools 3), 14 of
  them from sections tags, and 102 moved from 1:0 to their "type"
  value. 22 sections tags add 44 import and component nodes. The only
  new failed refs are a "multirow" section that cinquante-et-un's theme
  does not have, and 8 sections tags in theme-tools' prettier-plugin
  test fixtures that name a group no file provides.
- Cost: an extractor microbenchmark over 1,386 Liquid files (8 MB),
  median of 15 runs in 3 interleaved rounds, gave 436 ms on main and
  439 ms with the fix. Index wall time, median of 3 interleaved runs,
  main vs fix: horizon 2891 vs 3064 ms, chums-impulse-dev 2429 vs 2368,
  syncify 3846 vs 3810, theme-tools 6698 vs 6620. The byte-identical
  controls moved as much (express 2312 vs 2445, requests 1946 vs 2080),
  so that is noise on a shared machine.
- Rebased onto 08478ee, which adds only Pascal (PR #2810) and JS/TS
  resolution (PR #2811) changes. There the Liquid tests pass, and
  re-indexing the 8 theme repos gives graphs byte-identical to the
  pre-rebase fix arm, except for theme-tools' TypeScript calls, which
  PR #2811 changes.
- Kernel parity: not applicable, the kernel does not extract Liquid.

Fixes #2494

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inth3shadows added a commit to inth3shadows/codegraph that referenced this pull request Oct 25, 2026
Fork fixes colbymchenry#2588, colbymchenry#2766, colbymchenry#2807 superseded/merged upstream (maintainer
colbymchenry#2802, colbymchenry#2811, colbymchenry#2802). Removed from fork README carried-fixes list.

Fork-only items retained:
- sync stale-index check (colbymchenry#1842)
- sync-synthesis-input-package test
- ts-outer-declared-receiver test
- cli-sync-stale-index test
inth3shadows added a commit to inth3shadows/codegraph that referenced this pull request Oct 25, 2026
bompus added a commit to bompus/codegraph that referenced this pull request Oct 29, 2026
…ons it exposed (#582)

* fix(resolve): port upstream's lone same-file match confidence (cde4cd7)

A lone same-file definition chosen by findBestMatch scored by directory
proximity (0.7/0.4), losing to a framework's naming guess in another
file. is_decisive_same_file_match scores it 0.9 when it is the only
same-file candidate, is not the caller itself, and, as a member, belongs
to an owner the caller is inside.

Ports upstream cde4cd7 (colbymchenry#1938). same-file-match-confidence: 7/7.

* chore(resolve): dump the kernel profile at close(), not only at drop

The resolver is not dropped before process exit on the CLI index path, so
CODEGRAPH_KERNEL_PROF=1 accumulated timings that never printed. close()
is the deterministic teardown point.

* test(ts): assert the fork's native error-tree path for export type *

Upstream's kernel defers a file whose parse tree has errors, so the test
expected tryKernelExtract to return null. The fork's tsjs walker extracts
the recovered tree natively (cba9256) and keeps the re-export signature
as written — assert that contract instead.

* fix(resolve): port upstream's indexed import-path spelling (8651990)

An alias, workspace or direct-path join kept a specifier's lexical
spelling, so `@/widgets/Chart/` probed `Chart//index.tsx` and
`src/widgets/./Chart` probed `./` segments no files row is keyed by.
probe_extensions now spells each candidate as the index keys it for the
ES-module family; other languages keep the path as found.

Ports upstream 8651990 (colbymchenry#2792). import-path-spelling: 5/5.

* fix(resolve): port upstream's Dart library-privacy rule (f7820b5)

A Dart `_name` is private to its library — the library file and every
file its `part` directives name — not to its file. private_is_file_local
drops `dart`; is_visible_across_files gets the dart arm (a private
candidate is seen only from a file of its own library); and the
exact-name pre-pick filter declines a private candidate another library
declares so the caller's own library's declaration wins.

Ports upstream f7820b5 (colbymchenry#2832). dart-part-privacy: 10/12 — the two
remaining failures resolve a typed receiver's private method through
resolve_method_on_type's member path, whose visibility gate still needs
tracing (upstream's dart arm at name-matcher.ts ~13147 /
preferOwnDartLibrary is the next suspect).

* fix(resolve): vet every strategy's pick through is_visible_across_files

finish() applied name_post_guard but not the file/library-locality veto
resolveOne's nameResult gets at index.ts:1867, so typed-receiver picks
(instance-method) linked private members of another library. With the
dart arm in place this completes f7820b5: dart-part-privacy 12/12.

* fix(library): indexFiles keeps other writers out until its files are stored

The file lock was released as soon as indexing started — the promise
returned unawaited, the try ended, the finally let the lock go. Awaited,
the lock now holds until the files are stored, as indexAll and sync hold
it (upstream 865ddf4 / colbymchenry#2845).

* fix(resolve): let a framework own a reference past the name strategies

settleKernelOutcome merged kernel candidates beside the frameworks', so a
project namesake could answer a call Nuxt's navigateTo owns (upstream
58eb57a / colbymchenry#2826). With ownsReference set, the frameworks' best answer
wins or the ref stays unresolved.

* test(vue): assert the fork contract for tsx blocks — grammar always compiled in

Upstream's test asserted wasm-preload sets (9ee6718 / colbymchenry#2824); the fork
has no wasm loader, so a tsx <script> can never lack its grammar. The
block-mapping half was already fixed in sfcScriptLanguage.

* fix(resolve): finish() visibility guard on the final node, name picks only

Two corrections to the finish() is_visible_across_files port:

- Run it on the node after supertype/overload/alias retargets, the way
  upstream vets the target matchReference reports — a pre-forward object
  property or import alias is not the node upstream inspects.
- Vet only name-matcher picks: upstream's guard sits inside the
  matchReference arm, so import, file-path and framework results never
  reach it. An import pick's alias forward can legitimately land on an
  unexported module member (export const api = { run: right }).

Also ports the Rust arm upstream added for typed receivers: a method a
trait declares carries no pub of its own — reached through a typed
receiver it is the trait's (rust_trait_of + rust_typed_refs, marking
rust_written_call exits). Fixes the rust-* regressions the guard exposed
(rust-typed-receivers, rust-receiver-chains, rust-generic-bound-paths,
rust-method-value-types, rust-self-field-types, rust-wrapped-self-calls)
while keeping dart-part-privacy 12/12.

Remaining exposed failures are import-binding port debt, not guard bugs:
items$.getState().inc (import-type-modifier) and styled(Disclosure)
(function-ref-project-imports) resolve upstream through the import path
the kernel does not fully carry.

* feat(kernel): port Go value-type inference, indexed/chained/package-value call arms

Port goReceiverChainType/goElementOf/goPackageValueType semantics
tree-natively into the kernel: package-level var/const typing, indexed
and chained receiver calls, and declared-type terminal vetoes for
literals/outside types. Bound-receiver misses are terminal unless the
receiver is an asserted local the index cannot type (upstream
strategy-3 passthrough). TS gateTargetKind gains the missing upstream
arms (import self-edge, Go extends qualification, dot-imported
supertypes) and goBareTypeDir for type-position targets.

* fix(kernel): resolve Go package-value calls at typed-receiver confidence

Upstream's matchGoPackageValueCall resolves at 0.9; the arm inherited
go_method_in_package's 0.85.

* feat(kernel): Go element/field/call-result expression typing

goElementOf (named slice/map types resolve through their declarations),
goFieldTypeOf (struct field written types), selector-expression and
call-expression result arms in go_expr_written. Param/decl locals the
declaration reader misses fall back to infer_local_receiver_type.

* feat(kernel): Go chained/generic receivers, range elements, unread-file methods

* feat(kernel): Go build-constraint twins, external test packages, conversion refs (colbymchenry#2581)

Port upstream 800e582's three Go semantics into the kernel:

- A `pkg.Type(…)` conversion resolves its type through the import
  member arm — the kind filter now accepts Go exported member kinds
  (struct/interface/type_alias/variable/constant), which the TS
  edge-kind rewrite then turns into a `references` edge.
- `go_name_visible` is clause-aware: files sharing a directory but
  declaring different package clauses (`a` vs `a_test`) see each
  other's bare top-level names only through an import — qualified,
  or bare after a dot import and exported.
- New `go_build.rs` ports `goFileConstraint`/`preferGoBuildTwin`:
  `//go:build` and `// +build` expressions plus `_GOOS`/`_GOARCH`
  filename suffixes evaluate against the ordered GO_BUILD_TARGETS;
  a resolved target with constrained twins retargets to the twin
  the reference's own file builds with, and `go_pick_twin` collapses
  multi-candidate package members the import arm couldn't pick.

Also fixes the fork's `go-type-visibility.ts`: module-root packages
spell their dir `''` (matching `getGoPackageDir` and kernel
`pos_dirname`), so `goTypePositionTarget` retargets a namesake
function to the module-root type.

* feat(kernel): VB.NET namespace receivers, overload pick, head members (colbymchenry#2762)

Port upstream dbb6aa9: VbReceiver gains a namespace arm
(vb_known_namespaces/vb_namespace_around/vb_namespace_named/
vb_types_in_namespace/vb_module_member_in) so reads like
Billing.Invoice.MaxLines and Acme.Billing.Invoice.MaxLines link the
type or Module member the namespace declares; vb_takes_no_arguments +
vb_runnable_overload pick the overload VB.NET runs when a method is
named without parentheses (Me.Load, Optional/ParamArray, a ctor's
Me.New never resolves to itself); vb_head_member + vb_with_head link a
bare member before the dot (Button1.Text) when no local or parameter
shadows it, gated by foreign-Module and outside-namesake checks.
vb_receiver_type's member search is extracted as vb_member_around.

* feat(kernel): workspace package entries, path deps, manifest-edit sync (colbymchenry#2502, colbymchenry#2456)

Port e8ddc4e's declared-entry import resolution into the kernel and its
sync-side invalidation into codegraph.ts.

Kernel (napi config grows entriesByDir + scopedByName):
- resolve_workspace_import takes from_file; workspace_import_targets tries
  declared entries first — exports (exact, wildcard, fallback arrays,
  nested conditions), then source/module/main/types/typings in order —
  then an indexed direct probe, then emitted→source mapping, then the
  direct probe as last resort. Path deps (file:/link:/portal:) resolve
  scoped by the importer's nearest manifest, before global names;
  longest package name wins.
- imports.rs gains longest_package_name/match_workspace_package/
  declared_workspace_entries/indexed_target/built_source_of plus
  WorkspaceTargets/exported_targets/built_sources_of; prefilter passes
  the importing file through.

TS sync side (upstream index.ts port):
- resolver: refreshWorkspacePackages/getWorkspaceFingerprint/
  workspacePackageDirOf; a moved map closes the kernel since the config
  is construction-time.
- codegraph.ts: js_workspace_fingerprint metadata stamped at index and
  re-checked on full reconcile; a moved fingerprint re-opens every
  ESM-language ref for the orphan sweep. reopenReferencesThroughAddedFiles
  gets packageDirOf so a late-appearing declared entry re-links importers.
- loader.ts KernelWorkspaceIn + serialization gain the two new maps.

workspace-package-entries: 26/26. Regression sweep: 146/147, the one
failure a pre-existing tracked bucket (7180fd0 colbymchenry#2788).

* feat(kernel): a call on a this-field element resolves on the element's type

Port 449eefa's resolver half: `this.items[0].save()` arrives as
`this.items[].save` from the extractors (already ported) and now binds the
element type the field's declaration writes instead of bare-name matching
any project method.

- method_call_shape: elementOf arm `^this\.(#?[\w$]+)\[\]\.([\w$]+)$` →
  match_ts_this_field_call(field, method, r, element=true) — exclusive,
  like the plain `this.field.m` arm.
- TsFieldDecl gains element; ts_field_element_type reads it off the
  written type (`Item[]`, `Array<Item>`, `ReadonlyArray<Item>`,
  `Record<string, Item>`) and rejects unions, arrays of arrays and
  non-plain elements; ts_field_element adds tsFieldRead's multi-line
  continuation guard (`| Other[]` on the lines below).
- ts_field_held filters element reads through ts_class_type_parameter —
  `class Store<Item> { items: Item[] }` holds no project `Item`.
- ts_class_type_parameter ported upstream: `class|interface|type` keyword
  anchor, 24-line multi-line head, returns true when the list's `>` is
  not found (drop the type rather than take a parameter for a class).

ts-this-field-element 11/11; expression-receiver-calls +
ts-array-annotated-receivers green; receiver sweep shows only tracked
debt (08478ee colbymchenry#2811, 013b91c colbymchenry#2825); golden dumps unchanged.

* feat(kernel): calls on a typed local or parameter reach the builtin-named method (colbymchenry#2821)

A python call `reg.get()` on a builtin-named method was dropped by the
builtin filter before any strategy could read the receiver. Port
matchPythonTypedLocalCall (colbymchenry#2583) into python_attribute_verdict: a plain
local or parameter receiver settles only through scope evidence —
`python_local_class` agrees a binding def's parameter annotation (quoted,
Optional[T], Union[..., None], T | None, read off the raw def header) or
its assignments (ctor/factory/None; any foreign binding shape, rebinding
or contested evidence refuses). Members come from `python_strict_members`
— the class's own or a declared base's, resolved through the file's
imports, so a base from outside the project holds none of its methods
and the extends edges never substitute a same-name class.

Sync side: FAILED_PY_ATTR_REF widened to the one-dot `x.y` shape. The
fork's delta-narrowed retry keys (perf/sync-delta-retry) never list an
unchanged name like `get`, so a signature-only edit to the factory a
failed typed-local call reads its type from gave no retry key; the
attr-retry lane kernel-probes candidates and retries only resolvable
ones, which also lands the edge's typeFrom stamp for future edits.

* feat(kernel): a call on an unqualified call result resolves on its return type (colbymchenry#2822)

`repository().pending()` — and `val repo = repository()` locals — type the
receiver by the inner call's declared return, so `pending` is the method the
returned project type declares, never a same-named method elsewhere. A type
from outside the project leaves the name strategies untouched, and an
extension the bound-member walk can't see keeps the old name match.

The extractor's return_type keeps only a user_type's first identifier
(`Request`), so `kotlin_scoped_hit` retypes the callee through its signature
(`(): Request.Builder`) and writes a lone nested name through its declaring
outer (`Builder` → `Shop.Builder`).

Two pre-existing filters were misaligned with the kotlinCall/kotlinBare
split this relies on: member-scope reachability vetted receiver-written
names (`text().reverse`) as if receiver-less, and a Chain-shape call with a
non-project receiver type (`StringBuilder`) vetoed every name match —
upstream only constrains standard-library names there. Both now match
upstream's isReceiverLessKotlinCall / kotlinStdChain boundary.

Also: python_local_class returns Option<Answer> — a name no enclosing def
binds (module-level, global) is upstream's `undefined`, not a refused local,
which restores module-global `store = Store()` receivers the strict arm
claimed and dropped.

* feat(kernel): non-test refs resolve as if Jest manual mocks were absent (colbymchenry#2790)

Port upstream e69546e's mockless context: a ref from non-test code resolves
on a graph without the project's __mocks__/ files, while test code keeps the
whole graph. resolve_ref sets a per-ref mockless flag; nodes_by_name,
nodes_by_lower_name and nodes_by_qualified_name then drop __mocks__/ nodes
(gated on the cached mock-name sets so unaffected names aren't re-collected).
The TS callback-synthesis guards were already in place.

Also fix ts_scoped_reference's type-ref tail: upstream importedTypeMember
falls through (undefined) on a found-miss unless the specifier is outside
the repository — a resolved package directory whose exports can't be read
is not a refusal. The old gate refused references/extends refs bound to a
no-entry workspace package, which upstream answers by name-match.

* fix(sync): record files a JSX tag import reads through as synthesis inputs (colbymchenry#2563)

collectSynthesisInputs only kept files whose own content matched
mayFeedSynthesis, so a barrel or index that merely forwarded another
module's component was never recorded as an input. When a later sync
edited only that index, the JSX pass never reran and the tag kept its
stale endpoint.

Port upstream's importedTagModules: for each JSX-bearing file, map its
capitalized tags to project imports and collect every file
exportedComponent reads through, memoized per collection run.

* feat(kernel): resolve Rust calls by the receiver's written type (colbymchenry#2831)

Port upstream 8fdc8a1: a field chain or struct literal receiver's declared
type decides the call — `vis.map.get` is HashMap's, `Xyz{}.to_val` is Xyz's —
and a path call naming a type std or a dependency owns reaches only the
project's impls of that type or the named trait, never a project namesake.

- rust_expr_type types tuple-struct/enum-variant constructor calls
- undeclared-type guard limited to plain named `field_expression` heads,
  exempting generics, Self, outside types, use-aliases and wrapper-own
  methods; derived-trait provided methods resolve through `#[derive]`
- rust_path_call_reachable gates name-match on the path's outside type

Rust sweep 28 files/206 tests green; kernel golden dumps clean; the 16
remaining full-suite failures are all tracked port debt.

* feat(kernel): scope named class expressions and export them over CommonJS (colbymchenry#2825)

A named class expression is a class bound inside its expression: index
its members and supertypes, but resolve references written outside the
expression on a graph where that class and its members are not — a
same-named declaration or binding keeps its links, and `new Widget()`
elsewhere links nothing. References written inside see the whole graph
unless the name is another expression's, bound inside that one alone.

`module.exports = class Router` / `exports.Store = class StoreImpl`
are the module's value: the class stays reachable to every importer,
and collect_cjs_export records the declared name as the export's
local binding.

Inheritance refs resolved through an import binding emit upstream's
import confidence 0.9; the scoped arm's 0.95 stays for type-position
references.

* fix(kernel): a call or new never lands on an interface or a type alias (colbymchenry#2801)

Nothing calls an interface or a type alias, or makes an instance of one.
A calls/instantiates result that found a TypeScript type by name or
through an import meant the value its file declares beside it — the
function under `interface Ok` in a result module, the class merged with
an interface — and a global the project only types, like `new Response()`
or `new Worker()`, links nothing.

* fix(kernel): an explicit operator call reads its own argument list

tree-sitter-cpp parses `d.operator+=(c)` as a call on the receiver alone,
with the operator's name stranded in an ERROR sibling (`function:
(identifier) (ERROR ".operator+=") arguments: (c)`), so the callee never
spells `operator+=` and cpp_call_argument_types found no call. Every
overload then tied at 0 and the first — `operator+=(int)` — took a call
that `operator+=(const Counter&)` fits. Accept a call whose error spells
the operator name (the member-access dot is part of the error text), so
the argument types are read and the class overload wins.

`size_type` and `difference_type` count as numbers now, the container
convention upstream uses (6bd217a): nlohmann/json's `p->operator[](0)`
reaches the index overload, not the `T*` one.

* fix(kernel): a typed-local receiver keeps the invocation-time binding

The colbymchenry#2821 port (0b564c78) settled a builtin-named method call through
pythonLocalClass alone, which refuses when a name is bound more than
once. `store = A(); store = B(); store.get()` then resolved to nothing,
though the fork's receiver-scope rule has always read the binding in
effect at the call (B).

Read that binding: among plain assignments at or before the call, the
last one decides, and a bare annotation (`store: B`) does not rebind.
python_receiver_uncertain still holds back a same-line replacement and a
later replacement a closure's captured cell sees, and a later binding no
longer poisons an earlier one when the call reads before it. A def's
parameter keeps its annotation when nothing rebinds it.

Three shapes the strict read owns stay with it: a binding that is not a
plain assignment (a branch, loop, `with`, comprehension), a base from
outside the project, and a future binding read from a lambda body. A
receiver naming a class declared here (`File.write(f, "x")`) and a
lambda parameter of the receiver's name keep the ordinary paths.

* fix(resolve): vet only name picks through a module's unexported bindings

2ca95adb applied isVisibleAcrossFiles to every strategy's pick. Upstream
guards just the name match (index.ts:1867), and the port's ESM leg
vetoed picks that were never name guesses: a typed store action
(`items$.getState().inc()`) and an imported component function value
were both dropped as unexported module bindings. Keep every language's
privacy rule for a structured pick, and skip the ESM export check for a
pick a receiver's type or a function value made.

* test(eval): record the json, flask, vite and svelte precision runs

Every case held on each corpus (json 11 absent + 7 present, flask 2
present, vite 6 absent + 2 present, svelte 1 absent).

* fix(kernel): close the review findings on the three fixes

- C++ (P3): a comment inside the access (`b./* note */operator+=(a)`)
  left the comment in the error's text, so the operator name never
  matched. Compare the `operator_name` node the grammar still reads,
  and keep the trimmed-text form only when there is none.
- Python (P2): a local read before its only assignment in the same def
  (`result = store.get(); store = A()`) is an UnboundLocalError, not
  the later value; refuse it, keeping the future-initialization
  exception for a nested def that captures the outer name.
- Python (P2): two conditional bindings in different blocks leave no
  value in effect (`if flag: store = A() else: store = B()`, then
  `store.get()`); refuse. One conditional beside a `None` placeholder
  or a later plain assignment still reads, and a conflicting set whose
  binding in effect may not run stays unknown.
- ESM (P2): a function value is import-justified only when the file's
  own import resolves to the target's file, so a bare name fallback
  can no longer take an unexported namesake from another module. A
  default-exported wrapper still reaches its inner function through
  the default import, and `export default function Name` counts as an
  exported name.

Regression tests: commented operator access, a future local read, two
class-binding branches, and an imported name the module does not export.

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS: react-dom root.render() links to a class component's render() when root is declared outside

1 participant