mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:51:07 +01:00
Change DiagnoseDuplicateName to expect an inst ID for the duplicate. (#3616)
This makes duplicate and previous definition handling match. While we may want to make both point more fine-grained at the name, the necessary logic seems likely to be equivalent. Note, I'm looking at this mainly due to duplicate names in imports, where it's especially helpful to take an instruction instead of a parse node. We'll eventually want to handle parse nodes from other imports better, and I think this is the way it would most likely work.
This commit is contained in:
@@ -67,8 +67,7 @@ auto DeclNameStack::LookupOrAddName(NameContext name_context,
|
||||
|
||||
case NameContext::State::Unresolved:
|
||||
if (!name_context.target_scope_id.is_valid()) {
|
||||
context_->AddNameToLookup(name_context.parse_node,
|
||||
name_context.unresolved_name_id, target_id);
|
||||
context_->AddNameToLookup(name_context.unresolved_name_id, target_id);
|
||||
} else {
|
||||
auto& name_scope =
|
||||
context_->name_scopes().Get(name_context.target_scope_id);
|
||||
@@ -103,7 +102,7 @@ auto DeclNameStack::AddNameToLookup(NameContext name_context,
|
||||
SemIR::InstId target_id) -> void {
|
||||
auto existing_inst_id = LookupOrAddName(name_context, target_id);
|
||||
if (existing_inst_id.is_valid()) {
|
||||
context_->DiagnoseDuplicateName(name_context.parse_node, existing_inst_id);
|
||||
context_->DiagnoseDuplicateName(target_id, existing_inst_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user