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:
Jon Ross-Perkins authored and GitHub committed 2024-01-18 23:23:31 +00:00
1 parent af14a2586a
commit d0fb4b5815
9 files changed
+21 -25

No files matched your search

+1 -2
View File
@@ -164,7 +164,7 @@ static auto BuildFunctionDecl(Context& context,
}
} else {
// This is a redeclaration of something other than a function.
context.DiagnoseDuplicateName(name_context.parse_node, existing_id);
context.DiagnoseDuplicateName(function_decl_id, existing_id);
}
}
@@ -264,7 +264,6 @@ auto HandleFunctionDefinitionStart(Context& context,
if (auto fn_param = param.TryAs<SemIR::AnyBindName>()) {
context.AddNameToLookup(
context.insts().GetParseNode(param_id),
context.bind_names().Get(fn_param->bind_name_id).name_id, param_id);
} else {
CARBON_FATAL() << "Unexpected kind of parameter in function definition "