Fix cross-package signature mismatches. (#7232)

Fixes link failures when referencing a symbol involving a fingerprint
from a different package.

Previously we included the `Namespace`'s `import_id` as part of its
fingerprint, which caused local and imported namespaces to get different
fingerprints. We now store the `import_id` on the `NameScope` instead of
on the `Namespace` inst to avoid this problem.

Also, when we reach a package-level `NameScopeId`, consistently
fingerprint it as a (package name, library name) pair. Previously the
fingerprinting depended on whether it was imported or not, as an
imported `NameScopeId` had a parent scope (the current package). We need
to include the library name here so that private entities with the same
name in different libraries have different fingerprints.
This commit is contained in:
Richard Smith
2026-05-21 00:02:29 +00:00
committed by GitHub
parent 1231098c14
commit 05cc09daca
662 changed files with 51181 additions and 50920 deletions
+4 -2
View File
@@ -110,8 +110,10 @@ static auto GetAbsoluteNodeRefImpl(
// If a namespace has an instruction for an import, switch to looking at it.
if (auto ns = cursor_inst.TryAs<Namespace>()) {
if (ns->import_id.has_value()) {
cursor_inst_id = ns->import_id;
auto import_id =
cursor_ir->name_scopes().Get(ns->name_scope_id).import_id();
if (import_id.has_value()) {
cursor_inst_id = import_id;
continue;
}
}