Skip to content

Commit ec1e8b8

Browse files
committed
Merge branch 'gq-l5/stack-a-1907' into gq-l5/stack-a-1913
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2 parents db8d547 + e554a2a commit ec1e8b8

4 files changed

Lines changed: 51 additions & 16 deletions

File tree

‎src/pipeline/pass_parallel.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3298,7 +3298,15 @@ static void resolve_file_calls(resolve_ctx_t *rc, resolve_worker_state_t *ws, CB
32983298
}
32993299

33003300
_rc_t0 = extract_now_ns();
3301-
try_field_type_hint(rc, &res, call->callee_name, source_node->id);
3301+
/* Not for Go (F-G9): the hint matches the capitalized receiver
3302+
* VARIABLE name as a substring of a candidate QN (`t.Run` -> any
3303+
* `...T...Run`), with no type evidence. The sequential resolver has no
3304+
* such step, so for Go it produced parallel-only edges (par/seq CALLS
3305+
* diverged), and the Go selector guard could not see them as the weak
3306+
* pick they are. SCIP precision of Go field_type_hint: 0.016. */
3307+
if (lang != CBM_LANG_GO) {
3308+
try_field_type_hint(rc, &res, call->callee_name, source_node->id);
3309+
}
33023310
/* Cross-language veto — the same predicate as pass_calls.c, applied
33033311
* AFTER the field-type hint so the hint may still re-pick a compatible
33043312
* candidate first, and BEFORE the empty-resolution fallbacks below so a

‎src/pipeline/registry.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,18 +755,16 @@ bool cbm_go_suppress_weak_method_match(bool is_go, bool is_method, const char *s
755755
* short-name strategy binds it to an arbitrary same-named project symbol
756756
* (`f.Close()` on an os.File -> a project `Close`, suffix_match over 15
757757
* candidates). Built on the shared drop-list so "weak" means one thing
758-
* for every guard; Go narrows it in two places only. */
758+
* for every guard; Go narrows it in one place only (unique_name below).
759+
* field_type_hint stays weak: it is a receiver-NAME substring match, not
760+
* a declared-type lookup (the parallel resolver no longer produces it for
761+
* Go; a typed field call such as lrp_go_s8's `s.repo.Find()` resolves
762+
* through the Go LSP). */
759763
if (!is_go || !is_method || !weak_short_name_strategy(strategy)) {
760764
return false;
761765
}
762-
/* field_type_hint is KEPT for Go: a Go struct field carries a declared
763-
* type, so the parallel resolver's field-type hint is receiver-aware for
764-
* Go (lrp_go_s8_field_type_hint), not a heuristic. */
765-
if (strcmp(strategy, "field_type_hint") == 0) {
766-
return false;
767-
}
768766
if (strcmp(strategy, "unique_name") != 0) {
769-
return true; /* suffix_match, fuzzy */
767+
return true; /* suffix_match, field_type_hint, fuzzy */
770768
}
771769
/* unique_name is dropped only when PENALIZED: resolve_name_lookup scales
772770
* CONF_UNIQUE_NAME by DEFAULT_CONFIDENCE exactly when the lone candidate

‎tests/test_pipeline.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8806,6 +8806,30 @@ static void write_go_receiver_fixture(const char *tmp, int pad_files) {
88068806
"func CallsLocal() int { return localHelper() }\n"
88078807
"\n"
88088808
"func UsesUtil() string { return util.Tag() }\n");
8809+
/* F-G9: two project methods named Run, one under a directory whose QN
8810+
* carries an uppercase T. `t.Run` on a *testing.T must bind neither. The
8811+
* parallel resolver field-type hint matched the capitalized receiver
8812+
* variable ("T") as a QN substring and produced a par-only edge. */
8813+
write_temp_file(tmp, "TBench/bench.go",
8814+
"package tbench\n"
8815+
"\n"
8816+
"type Bench struct{}\n"
8817+
"\n"
8818+
"func (b *Bench) Run(name string) bool { return name != \"\" }\n");
8819+
write_temp_file(tmp, "worker/worker.go",
8820+
"package worker\n"
8821+
"\n"
8822+
"type Worker struct{}\n"
8823+
"\n"
8824+
"func (w *Worker) Run(name string) bool { return false }\n");
8825+
write_temp_file(tmp, "hash/hash_test.go",
8826+
"package hash\n"
8827+
"\n"
8828+
"import \"testing\"\n"
8829+
"\n"
8830+
"func TestSubRun(t *testing.T) {\n"
8831+
"\tt.Run(\"a\", func(t *testing.T) {})\n"
8832+
"}\n");
88098833
for (int i = 0; i < pad_files; i++) {
88108834
char name[64];
88118835
char body[128];
@@ -8843,6 +8867,8 @@ TEST(pipeline_go_receiver_suppresses_weak_method_edge) {
88438867
/* (4) The import-qualified cross-package call survives (import-aware
88448868
* strategies are outside the drop-list). */
88458869
ASSERT_TRUE(cross_file_call_exists(s, project, "UsesUtil", "Tag"));
8870+
/* (5) F-G9: the stdlib *testing.T Run binds no project Run. */
8871+
ASSERT_FALSE(cross_file_call_exists(s, project, "TestSubRun", "Run"));
88468872

88478873
cbm_store_close(s);
88488874
cbm_pipeline_free(p);
@@ -8886,6 +8912,8 @@ TEST(pipeline_go_receiver_parallel_suppresses_weak_method_edge) {
88868912
ASSERT_TRUE(cross_file_call_exists(s, project, "Boot", "Close"));
88878913
ASSERT_TRUE(cross_file_call_exists(s, project, "CallsLocal", "localHelper"));
88888914
ASSERT_TRUE(cross_file_call_exists(s, project, "UsesUtil", "Tag"));
8915+
/* F-G9: the parallel-only field-type hint must not bind `t.Run` either. */
8916+
ASSERT_FALSE(cross_file_call_exists(s, project, "TestSubRun", "Run"));
88898917

88908918
cbm_store_close(s);
88918919
cbm_pipeline_free(p);

‎tests/test_registry.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,11 +1673,12 @@ TEST(weak_call_guards_share_one_drop_list) {
16731673
strategies[i], member, binding);
16741674
}
16751675
ASSERT_EQ(member, binding);
1676-
/* The Go selector guard builds on the same list and narrows it in
1677-
* exactly one place at a penalized confidence (0.75 * 0.5): it keeps
1678-
* field_type_hint. Any other drift from the shared list fails here. */
1676+
/* The Go selector guard builds on the same list. At a penalized
1677+
* confidence (0.75 * 0.5) it agrees with it exactly; its one narrowing
1678+
* (an unpenalized unique_name) does not apply here. Any drift from
1679+
* the shared list fails here. */
16791680
bool go = cbm_go_suppress_weak_method_match(true, true, strategies[i], 0.375);
1680-
bool go_expected = member && strcmp(strategies[i], "field_type_hint") != 0;
1681+
bool go_expected = member;
16811682
if (go != go_expected) {
16821683
printf(" Go drop-list divergence on strategy \"%s\": go=%d expected=%d\n",
16831684
strategies[i], go, go_expected);
@@ -1697,6 +1698,9 @@ TEST(go_suppress_drops_weak_selector_matches) {
16971698
ASSERT_TRUE(cbm_go_suppress_weak_method_match(true, true, "suffix_match", 0.11));
16981699
ASSERT_TRUE(cbm_go_suppress_weak_method_match(true, true, "fuzzy", 0.9));
16991700
ASSERT_TRUE(cbm_go_suppress_weak_method_match(true, true, "unique_name", 0.375));
1701+
/* field_type_hint is a receiver-NAME substring match, not type evidence
1702+
* (F-G9): weak for Go like the shared list. */
1703+
ASSERT_TRUE(cbm_go_suppress_weak_method_match(true, true, "field_type_hint", 0.85));
17001704
PASS();
17011705
}
17021706

@@ -1706,9 +1710,6 @@ TEST(go_suppress_keeps_typed_and_import_aware_matches) {
17061710
* lone-candidate call never enters the field-type-hint upgrade, so it must
17071711
* survive (lrp_go_s8_field_type_hint). */
17081712
ASSERT_FALSE(cbm_go_suppress_weak_method_match(true, true, "unique_name", 0.75));
1709-
/* field_type_hint is receiver-aware for Go — struct fields carry declared
1710-
* types (lrp_go_s8_field_type_hint) — so it stays, unlike the TS/JS list. */
1711-
ASSERT_FALSE(cbm_go_suppress_weak_method_match(true, true, "field_type_hint", 0.85));
17121713
ASSERT_FALSE(cbm_go_suppress_weak_method_match(true, true, "same_module", 0.9));
17131714
ASSERT_FALSE(cbm_go_suppress_weak_method_match(true, true, "import_map", 0.95));
17141715
ASSERT_FALSE(cbm_go_suppress_weak_method_match(true, true, "import_map_suffix", 0.9));

0 commit comments

Comments
 (0)