Description
Summary
resolveCallTargets (src/domain/graph/builder/call-resolver.ts) resolves a call's targets as follows:
if (!targets || targets.length === 0) {
targets = lookup.byNameAndFile(call.name, relPath); // <-- unqualified, same-file, NO kind filter
if (targets.length === 0) {
targets = resolveByMethodOrGlobal(lookup, call, relPath, typeMap, callerName);
}
}This bare lookup.byNameAndFile(call.name, relPath) step runs unconditionally for every call (regardless of receiver — this.x(), obj.x(), bare x() are all treated the same at this step) and is not filtered by symbol kind. If any same-file node happens to share the call's bare name — a class, an interface, a top-level const/variable binding, anything — it wins immediately, before any receiver-type-aware resolution (resolveByReceiver, resolveByGlobal, the same-class qualified-method fallback, etc.) ever gets a chance to run.
This means a call can resolve to a same-named class/variable even when a correctly-typed, legitimately-callable target also exists via qualified lookup — the bare unqualified match is checked first and wins by construction.
Repro
class Registry {
bar() {
return 1;
}
}
const obj = new Registry();
function getter() {
this.bar();
}
Object.defineProperty(obj, 'x', { get: getter });
class bar {}Building this (either engine — confirmed identical on both wasm and native, so this is a correctness bug, not an engine-parity gap) produces:
getter -> bar (kind: class) ❌ wrong — should be Registry.bar (kind: method)
Removing the trailing class bar {} makes it resolve correctly to Registry.bar (kind: method) on the WASM engine (confirms Registry.bar — a real, correctly-typed target — was reachable and correct; it's specifically being pre-empted by the coincidentally-named class).
Why this matters
This is the actual mechanism by which an "unrelated same-named class/variable" can produce a nonsensical calls edge — it happens at the shared, universal resolveCallTargets primary-resolution step, not in any receiver-specific or defineProperty-specific fallback. It affects every call site in every supported language that goes through this JS/WASM resolution path, not just Object.defineProperty accessors. (It's already identical between full-build and incremental — both call the same shared resolveCallTargets — so this is not a parity divergence, just a plain correctness bug.)
Suggested fix direction
This needs careful design, not a quick patch — the unqualified same-file lookup is presumably relied upon for legitimate cases (e.g. calling a function-valued const/variable binding), so a blanket kind filter could regress those. Options to evaluate:
- Only treat the bare same-file match as authoritative when its kind is in a "callable-ish" set (function/method, plus whatever binding kinds legitimately hold callable values), falling through to type-aware resolution otherwise.
- Try type/receiver-aware resolution first when a receiver is present (
this/obj/etc.), and only use the bare same-file lookup as a last-resort fallback for genuinely bare, receiver-less calls.
Given the potential blast radius (this is the primary resolution step for all 34 supported languages), this should get its own focused investigation + full resolution-benchmark regression run, not be bundled into an unrelated fix.
Found while working on #1766 (Object.defineProperty accessor fallback kind-filter unification) — out of scope there since #1766's fix only touches a last-resort fallback tier that (per this same investigation) turns out to never fire with a different result than this primary lookup already would have produced.
Activity
carlos-alm commentedon Jul 30, 2026
Already resolved — this exact fix landed in the squashed PR #2026 (
fa678d41, "fix(resolver): kind-filter same-file bare-name lookup for receiver-bearing calls"), which only referenced this issue (Refs #1888) rather than closing it, so it stayed open despite being fixed.The implemented fix matches this issue's suggested option 1 exactly: the same-file bare-name lookup now filters to
CALLABLE_SYMBOL_KINDS(function/method) whenever the call has a receiver (this.x()/obj.x()), and is left unfiltered only for genuinely bare calls (to preservenew ClassName()constructor resolution) — implemented identically in bothcall-resolver.ts(JS/TS/WASM) and the mirrored Rustis_callable_kindfilter inbuild_edges.rs, so both engines agree.A dedicated regression test exists and passes on both engines:
tests/integration/issue-1888-same-file-bare-name-kind-filter.test.ts(verified vianpx vitest run, 4/4 passed) — it reproduces this issue's exactObject.defineProperty+ coincidentally-named-class repro and confirms it now resolves toRegistry.bar(method), not the unrelatedbarclass. Closing as resolved.fix: confirm concrete-receiver bare-name matches via type-aware dispa…
fix(ci): add non-blocking reminder for non-closing issue references i…