When diagnosing a duplicated name, add the name to the diagnosis (#4902)

In order to have the name available for diagnostics, we now always set
`NameId` in `NameContext` and put `poisoning_loc_id` as part of the
union with `resolved_inst_id` instead (since we never need both).
This commit is contained in:
Boaz Brickner
2025-02-19 07:19:23 +00:00
committed by GitHub
parent e0b2f5d772
commit 6a99c4e970
40 changed files with 104 additions and 96 deletions
+3 -2
View File
@@ -138,7 +138,8 @@ auto GetCanonicalImportIRInst(Context& context, SemIR::InstId inst_id)
return GetCanonicalImportIRInst(context, &context.sem_ir(), inst_id);
}
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id,
auto VerifySameCanonicalImportIRInst(Context& context, SemIR::NameId name_id,
SemIR::InstId prev_id,
SemIR::ImportIRInst prev_import_ir_inst,
SemIR::ImportIRId new_ir_id,
const SemIR::File* new_import_ir,
@@ -151,7 +152,7 @@ auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id,
auto conflict_id =
AddImportRef(context, {.ir_id = new_ir_id, .inst_id = new_inst_id});
// TODO: Pass the imported name location instead of the conflict id.
DiagnoseDuplicateName(context, conflict_id, prev_id);
DiagnoseDuplicateName(context, name_id, conflict_id, prev_id);
}
// Returns an instruction that has the specified constant value.