Skip to content

Commit 51c57c4

Browse files
committed
fix(pipeline): refuse same_module for import-bound or builtin JS/TS receivers
Strategy 2 (same_module) looks a member callee up a second time without its receiver, so `axios.get(url)` in a file that defines its own `get` became a 0.90 CALLS edge to that local function. The weak-member guard deliberately keeps same_module, so this class was unguarded (#1128). Restore the registry strategy chain to main (review of 2026-10-19, item 1): the chain also resolves type references, field types, reads/writes, SQL lineage and the cross-LSP pass for every language, and the chain-level restriction broke the C typed-field and Python external-import pipeline tests. Instead add a call-site suppressor, wired identically in pass_calls.c and pass_parallel.c with the language list inside the helper: for the JS/TS family and the <script> hosts it drops the plain-CALLS fall-through only when the receiver-dropping lookup produced the hit AND the receiver is bound to an ES import or a CommonJS require of the file, to an AMD dependency, or is a builtin global of the JS runtime (console, Math, JSON, Object, process, ...). Every other receiver keeps its edge: object-literal methods and functions assigned onto an object are stored at module level, so `context.push()` reaching the module's `push` is usually right. A whole-callee hit (`search.init()` -> <module>.search.init) keeps the receiver in the match and is never refused. Service and route edges are unaffected. Measured with a fresh full index, sequential and parallel identical, runs repeatable: vuejs/core same_module CALLS 1309 -> 1304, NodeBB 1721 -> 1680, no other strategy moves and no edge is added; every one of the 49 removed call sites was read against the source and is a wrong edge. helm (Go) is byte-identical. The contributor's registry cases move to the guard as positive and negative controls; pipeline tests cover JS, TS, TSX, ArkTS, Vue, Svelte, Astro and HTML plus CommonJS and AMD, sequential and parallel, and fail on main for every language. Signed-off-by: Martin Vogel <[email protected]>
1 parent 34c64bf commit 51c57c4

6 files changed

Lines changed: 599 additions & 262 deletions

File tree

‎src/pipeline/pass_calls.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,13 @@ static int resolve_single_call(cbm_pipeline_ctx_t *ctx, CBMCall *call, const CBM
11261126
* paths are module chains) — MUST match pass_parallel.c exactly. */
11271127
(lang == CBM_LANG_PYTHON && cbm_suppress_weak_import_bound_call(true, true, res.strategy) &&
11281128
cbm_python_import_binding_contradicts(imports, call->callee_name, res.qualified_name,
1129-
ctx->gbuf, ctx->project_name, rel));
1129+
ctx->gbuf, ctx->project_name, rel)) ||
1130+
/* Same-module bound-receiver suppression (#1128): `axios.get()` with
1131+
* axios imported must not bind the `get` this file happens to define.
1132+
* The language list is inside the helper - MUST match pass_parallel.c. */
1133+
cbm_suppress_same_module_bound_receiver(lang, call->is_method, call->callee_name,
1134+
res.qualified_name, res.strategy, imports,
1135+
call->receiver_is_amd_dependency);
11301136

11311137
/* Service-pattern HTTP/ASYNC calls to an EXTERNAL client library (e.g.
11321138
* `requests.get("/api/orders/{id}")`) resolve to a QN containing the library

‎src/pipeline/pass_parallel.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,12 @@ static void resolve_file_calls(resolve_ctx_t *rc, resolve_worker_state_t *ws, CB
33593359
cbm_suppress_weak_import_bound_call(true, true, res.strategy) &&
33603360
cbm_python_import_binding_contradicts(&result->imports, call->callee_name,
33613361
res.qualified_name, rc->main_gbuf,
3362-
rc->project_name, rel));
3362+
rc->project_name, rel)) ||
3363+
/* Same-module bound-receiver suppression (#1128) - see pass_calls.c;
3364+
* the language list is inside the helper, so the two cannot drift. */
3365+
cbm_suppress_same_module_bound_receiver(
3366+
lang, call->is_method, call->callee_name, res.qualified_name, res.strategy,
3367+
&result->imports, call->receiver_is_amd_dependency);
33633368

33643369
/* Service-pattern HTTP/ASYNC client call (`requests.get(url)`): the
33653370
* service signal lives in the callee_name. The registry can mis-resolve

‎src/pipeline/pipeline_internal.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,23 @@ bool cbm_python_import_binding_contradicts(const CBMImportArray *imports, const
907907
const char *resolved_qn, const cbm_gbuf_t *gbuf,
908908
const char *project_name, const char *rel_path);
909909

910+
/* #1128: true when a JS/TS-family member call resolved by `same_module` only
911+
* through the lookup that drops its receiver (`resolved_qn` does not end in the
912+
* whole callee), while that receiver is bound to an import of the file
913+
* (`file_imports`: ES import or CommonJS require), to an AMD dependency
914+
* (`receiver_is_amd_dependency`, the extractor's per-call fact), or is a
915+
* builtin global of the JS runtime (`console`, `Math`, `JSON`, ...):
916+
* `axios.get()` must not bind the `get` this file happens to define. Any other
917+
* receiver keeps the edge (`context.push()` onto an object-literal method
918+
* stored at module level). The language list is inside the helper, so
919+
* pass_calls.c and pass_parallel.c cannot drift. Only the plain-CALLS
920+
* fall-through is dropped. Pure; unit-tested in test_registry.c. */
921+
bool cbm_suppress_same_module_bound_receiver(CBMLanguage lang, bool is_method,
922+
const char *callee_name, const char *resolved_qn,
923+
const char *strategy,
924+
const CBMImportArray *file_imports,
925+
bool receiver_is_amd_dependency);
926+
910927
/* Base-class twin: true when a Python base spelling (`unittest.TestCase`,
911928
* `TestCase` under `from unittest import TestCase`, `ut.TestCase` under
912929
* `import unittest as ut`) is bound by an EXTERNAL import whose chain

0 commit comments

Comments
 (0)