Skip to content

Commit f5ec03f

Browse files
fix(pipeline): suppress import_map cross-lang CALLS homonyms (#1572)
Sequential #1572 still emitted two CALLS after the lsp_* guard because registry import_map can bind `unittest.mock.patch` calls to an in-repo TSX `patch` symbol. Drop any resolver strategy once the target is a cross- language unique_name homonym (keep same_module and lsp_builtin*). Signed-off-by: rudi193-cmd <rudi193@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 24795fc commit f5ec03f

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎src/pipeline/pipeline.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ bool cbm_suppress_weak_local_binding_call(bool enabled, bool callee_is_locally_b
330330
bool cbm_suppress_cross_language_suffix_match(CBMLanguage caller_lang, const char *target_file_path,
331331
const char *strategy);
332332

333-
/* CALLS emission guard: suffix_match / unique_name (#725/#1572) plus in-repo
334-
* LSP bare-name binds (lsp_direct, lsp_callable_alias, …) that share the
335-
* #1572 homonym class with registry unique_name. */
333+
/* CALLS emission guard: suffix_match / unique_name (#725/#1572) plus any other
334+
* strategy that binds a cross-language unique_name homonym (import_map, lsp_*,
335+
* …). */
336336
bool cbm_suppress_cross_language_calls_edge(CBMLanguage caller_lang, const char *target_file_path,
337337
const char *strategy);
338338

‎src/pipeline/registry.c‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,20 +769,31 @@ static bool lsp_strategy_is_external_builtin(const char *strategy) {
769769
strcmp(strategy, "lsp_builtin_constructor") == 0;
770770
}
771771

772+
static bool cross_language_unique_name_homonym(CBMLanguage caller_lang,
773+
const char *target_file_path) {
774+
return cbm_suppress_cross_language_suffix_match(caller_lang, target_file_path,
775+
"unique_name");
776+
}
777+
772778
bool cbm_suppress_cross_language_calls_edge(CBMLanguage caller_lang, const char *target_file_path,
773779
const char *strategy) {
774780
if (cbm_suppress_cross_language_suffix_match(caller_lang, target_file_path, strategy)) {
775781
return true;
776782
}
777-
/* #1572 pipeline: registry unique_name and Python-LSP bare-name binds
778-
* (lsp_direct, lsp_callable_alias, …) are the same homonym class across
779-
* languages. Import-aware lsp_import_alias to stdlib QNs stays same-language
780-
* or off-graph; in-repo cross-language targets are still dropped. */
781-
if (!strategy || strncmp(strategy, "lsp_", 4) != 0 ||
782-
lsp_strategy_is_external_builtin(strategy)) {
783+
/* #1572 / #725 pipeline: once the target is a cross-language unique_name
784+
* homonym, every weak resolver (import_map, lsp_*, suffix_match, …) is the
785+
* same failure mode as registry unique_name. Keep same_module (true local
786+
* callee) and stdlib lsp_builtin* (usually off-graph). */
787+
if (!cross_language_unique_name_homonym(caller_lang, target_file_path)) {
788+
return false;
789+
}
790+
if (strategy && strcmp(strategy, "same_module") == 0) {
783791
return false;
784792
}
785-
return cbm_suppress_cross_language_suffix_match(caller_lang, target_file_path, "unique_name");
793+
if (lsp_strategy_is_external_builtin(strategy)) {
794+
return false;
795+
}
796+
return true;
786797
}
787798

788799
bool cbm_suppress_cross_language_ref(CBMLanguage caller_lang, const char *target_file_path) {

‎tests/test_registry.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,14 @@ TEST(cross_language_calls_edge_treats_lsp_direct_homonym_as_unique_name) {
10281028
"lsp_callable_alias"));
10291029
ASSERT_TRUE(cbm_suppress_cross_language_calls_edge(CBM_LANG_PYTHON, "frontend/Panel.tsx",
10301030
"lsp_override"));
1031+
ASSERT_TRUE(cbm_suppress_cross_language_calls_edge(CBM_LANG_PYTHON, "frontend/Panel.tsx",
1032+
"import_map"));
1033+
ASSERT_TRUE(cbm_suppress_cross_language_calls_edge(CBM_LANG_PYTHON, "frontend/Panel.tsx",
1034+
"import_map_suffix"));
10311035
ASSERT_FALSE(cbm_suppress_cross_language_calls_edge(CBM_LANG_PYTHON, "frontend/Panel.tsx",
10321036
"lsp_builtin"));
1037+
ASSERT_FALSE(cbm_suppress_cross_language_calls_edge(CBM_LANG_PYTHON, "backend/test_thing.py",
1038+
"import_map"));
10331039
PASS();
10341040
}
10351041

0 commit comments

Comments
 (0)