@@ -5893,6 +5893,91 @@ TEST(pipeline_python_cross_module_call) {
58935893 PASS ();
58945894}
58955895
5896+ /* #725: two same-named symbols across languages must not share CALLS edges.
5897+ * Python Store.commit is the real callee of save(); the JS Editor.commit
5898+ * function is a distinct binding and must have no inbound CALLS from Python.
5899+ * unique_name (candidates==1) is #1572 and is not this claim. */
5900+ TEST (pipeline_cross_language_same_name_does_not_share_calls_issue725 ) {
5901+ const char * files [] = {"store.py" , "app.py" , "web/src/pages/Editor.js" };
5902+ const char * contents [] = {
5903+ "class Store:\n"
5904+ " def commit(self):\n"
5905+ " return True\n" ,
5906+
5907+ "from store import Store\n"
5908+ "\n"
5909+ "def save():\n"
5910+ " return Store().commit()\n" ,
5911+
5912+ "export function commit() {\n"
5913+ " return 1;\n"
5914+ "}\n" };
5915+
5916+ if (setup_lang_repo (files , contents , 3 ) != 0 )
5917+ FAIL ("tmpdir" );
5918+ char db [512 ];
5919+ snprintf (db , sizeof (db ), "%s/test.db" , g_lang_tmpdir );
5920+
5921+ cbm_pipeline_t * p = cbm_pipeline_new (g_lang_tmpdir , db , CBM_MODE_FULL );
5922+ ASSERT_NOT_NULL (p );
5923+ ASSERT_EQ (cbm_pipeline_run (p ), 0 );
5924+
5925+ cbm_store_t * s = cbm_store_open_path (db );
5926+ ASSERT_NOT_NULL (s );
5927+ const char * proj = cbm_pipeline_project_name (p );
5928+
5929+ cbm_node_t * commits = NULL ;
5930+ int ncommit = 0 ;
5931+ cbm_store_find_nodes_by_name (s , proj , "commit" , & commits , & ncommit );
5932+ ASSERT_GTE (ncommit , 2 );
5933+
5934+ int64_t js_id = 0 ;
5935+ int64_t py_id = 0 ;
5936+ for (int i = 0 ; i < ncommit ; i ++ ) {
5937+ if (commits [i ].file_path && strstr (commits [i ].file_path , "Editor.js" ))
5938+ js_id = commits [i ].id ;
5939+ if (commits [i ].file_path && strstr (commits [i ].file_path , "store.py" ))
5940+ py_id = commits [i ].id ;
5941+ }
5942+ ASSERT_TRUE (js_id != 0 );
5943+ ASSERT_TRUE (py_id != 0 );
5944+
5945+ cbm_node_t * saves = NULL ;
5946+ int nsave = 0 ;
5947+ cbm_store_find_nodes_by_name (s , proj , "save" , & saves , & nsave );
5948+ ASSERT_GT (nsave , 0 );
5949+
5950+ cbm_edge_t * from_save = NULL ;
5951+ int nfrom = 0 ;
5952+ cbm_store_find_edges_by_source_type (s , saves [0 ].id , "CALLS" , & from_save , & nfrom );
5953+ bool save_calls_py = false;
5954+ bool save_calls_js = false;
5955+ for (int i = 0 ; i < nfrom ; i ++ ) {
5956+ if (from_save [i ].target_id == py_id )
5957+ save_calls_py = true;
5958+ if (from_save [i ].target_id == js_id )
5959+ save_calls_js = true;
5960+ }
5961+ ASSERT_TRUE (save_calls_py );
5962+ ASSERT_FALSE (save_calls_js );
5963+
5964+ cbm_edge_t * into_js = NULL ;
5965+ int njs = 0 ;
5966+ cbm_store_find_edges_by_target_type (s , js_id , "CALLS" , & into_js , & njs );
5967+ ASSERT_EQ (njs , 0 );
5968+
5969+ if (from_save )
5970+ cbm_store_free_edges (from_save , nfrom );
5971+ if (into_js )
5972+ cbm_store_free_edges (into_js , njs );
5973+ cbm_store_free_nodes (commits , ncommit );
5974+ cbm_store_free_nodes (saves , nsave );
5975+ cbm_store_close (s );
5976+ cbm_pipeline_free (p );
5977+ teardown_lang_repo ();
5978+ PASS ();
5979+ }
5980+
58965981TEST (pipeline_go_type_classification ) {
58975982 /* Port of TestGoTypeClassification */
58985983 const char * files [] = {"types.go" };
@@ -11668,6 +11753,7 @@ SUITE(pipeline) {
1166811753 RUN_TEST (pipeline_go_cross_package_call );
1166911754 RUN_TEST (pipeline_swift_cross_package_import );
1167011755 RUN_TEST (pipeline_python_cross_module_call );
11756+ RUN_TEST (pipeline_cross_language_same_name_does_not_share_calls_issue725 );
1167111757 RUN_TEST (pipeline_go_type_classification );
1167211758 RUN_TEST (pipeline_go_grouped_types );
1167311759 RUN_TEST (pipeline_kotlin_project );
0 commit comments