From 5fcdb2d79152aabe11544d2493390d0ccb9e09e7 Mon Sep 17 00:00:00 2001 From: "samie a." <90323643+abdulsamie10@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:12:22 +0500 Subject: [PATCH] test: pin in-file calls to salted Rust functions and Go ids outside a collision group Two guards for the review questions on #4468: an in-file call to `ignore()`, `e()` or `E()` binds by the name as written and reaches the salted node (on v8 the calls to `ignore()` and `E()` bind nowhere, since those functions had no node), and the other types in a Go file that holds a case-only pair keep the ids they have without the pair. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 5c49344807c512735e962dd8636f86ba3623b5ba) --- tests/test_go_qualified_resolution.py | 13 +++++++++++++ tests/test_rust_case_collisions.py | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/test_go_qualified_resolution.py b/tests/test_go_qualified_resolution.py index f5e0e6359..3bb766ba8 100644 --- a/tests/test_go_qualified_resolution.py +++ b/tests/test_go_qualified_resolution.py @@ -447,3 +447,16 @@ def test_case_only_sibling_type_ids_do_not_depend_on_declaration_order(tmp_path: forward = ids(_gin_corpus(tmp_path, _GIN_IFACE, _GIN_STRUCT, _GIN_CONTEXT)) backward = ids(_gin_corpus(tmp_path, _GIN_STRUCT, _GIN_IFACE, _GIN_CONTEXT)) assert forward == backward + + +def test_non_colliding_types_keep_their_ids_beside_a_colliding_pair(tmp_path: Path) -> None: + """Only the members of a collision group can move: the other types in the + file, exported or not, keep the ids they have in a file without the pair.""" + other = "type node struct {\n\tpath string\n}\n" + + def ids(result: dict) -> dict[str, str]: + return {n["label"]: n["id"] for n in result["nodes"] + if n.get("label") in ("Context", "node")} + + alone = ids(_gin_corpus(tmp_path, _GIN_CONTEXT, other)) + assert ids(_gin_corpus(tmp_path, _GIN_IFACE, _GIN_STRUCT, _GIN_CONTEXT, other)) == alone diff --git a/tests/test_rust_case_collisions.py b/tests/test_rust_case_collisions.py index b847e9d3b..5bfd7145e 100644 --- a/tests/test_rust_case_collisions.py +++ b/tests/test_rust_case_collisions.py @@ -159,3 +159,15 @@ def test_forward_reference_to_the_retained_type_lands_on_it(tmp_path: Path) -> N assert [(n["label"], Path(n["source_file"]).name if n.get("source_file") else "") for n in targets] == [("Ignore", "dir.rs")] + +def test_calls_to_salted_functions_keep_their_in_file_edges(tmp_path: Path) -> None: + """In-file calls bind by the name as written, so they reach the salted ids.""" + result = _extract( + tmp_path, + _IGNORE_RS + + "\nfn e(s: &str) -> u32 {\n 1\n}\n" + + "\nfn E(s: &str) -> u32 {\n 2\n}\n" + + "\nfn caller() -> u32 {\n let _ = ignore();\n e(\"a\") + E(\"b\")\n}\n", + ) + calls = _edges(result, "calls") + assert {("caller()", "ignore()"), ("caller()", "e()"), ("caller()", "E()")} <= calls, calls