@@ -223,15 +223,15 @@ auto Context::DiagnoseDuplicateName(SemIRLoc dup_def, SemIRLoc prev_def)
223223 .Emit ();
224224}
225225
226- auto Context::DiagnosePoisonedName (SemIR::InstId loc) -> void {
227- // TODO: Improve the diagnostic to replace NodeId::None with the location
228- // where the name was poisoned. See discussion in
229- // https://github.com/carbon-language/carbon-lang/pull/4654#discussion_r1876607172
226+ auto Context::DiagnosePoisonedName (SemIR::LocId poisoning_loc_id,
227+ SemIR::InstId decl_inst_id) -> void {
228+ CARBON_CHECK (poisoning_loc_id. has_value (),
229+ " Trying to diagnose poisoned name with no poisoning location " );
230230 CARBON_DIAGNOSTIC (NameUseBeforeDecl, Error,
231231 " name used before it was declared" );
232232 CARBON_DIAGNOSTIC (NameUseBeforeDeclNote, Note, " declared here" );
233- emitter_->Build (SemIR::LocId::None , NameUseBeforeDecl)
234- .Note (loc , NameUseBeforeDeclNote)
233+ emitter_->Build (poisoning_loc_id , NameUseBeforeDecl)
234+ .Note (decl_inst_id , NameUseBeforeDeclNote)
235235 .Emit ();
236236}
237237
@@ -421,13 +421,14 @@ auto Context::LookupUnqualifiedName(Parse::NodeId node_id,
421421 .scope_result = SemIR::ScopeLookupResult::MakeError ()};
422422}
423423
424- auto Context::LookupNameInExactScope (SemIRLoc loc , SemIR::NameId name_id,
424+ auto Context::LookupNameInExactScope (SemIR::LocId loc_id , SemIR::NameId name_id,
425425 SemIR::NameScopeId scope_id,
426426 SemIR::NameScope& scope,
427427 bool is_being_declared)
428428 -> SemIR::ScopeLookupResult {
429- if (auto entry_id = is_being_declared ? scope.Lookup (name_id)
430- : scope.LookupOrPoison (name_id)) {
429+ if (auto entry_id = is_being_declared
430+ ? scope.Lookup (name_id)
431+ : scope.LookupOrPoison (loc_id, name_id)) {
431432 auto lookup_result = scope.GetEntry (*entry_id).result ;
432433 if (!lookup_result.is_poisoned ()) {
433434 LoadImportRef (*this , lookup_result.target_inst_id ());
@@ -438,7 +439,7 @@ auto Context::LookupNameInExactScope(SemIRLoc loc, SemIR::NameId name_id,
438439 if (!scope.import_ir_scopes ().empty ()) {
439440 // TODO: Enforce other access modifiers for imports.
440441 return SemIR::ScopeLookupResult::MakeWrappedLookupResult (
441- ImportNameFromOtherPackage (*this , loc , scope_id,
442+ ImportNameFromOtherPackage (*this , loc_id , scope_id,
442443 scope.import_ir_scopes (), name_id),
443444 SemIR::AccessKind::Public);
444445 }
0 commit comments