mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
When diagnosing a duplicate name, point to the name instead of the instruction (#4953)
Left TODOs where more work is necessary before this change can be applied or its impact can be verified. Includes #4952, to avoid regression in some cases. Similar to #4938. See https://discord.com/channels/655572317891461132/655578254970716160/1339007384361762857.
This commit is contained in:
@@ -138,7 +138,7 @@ static auto MergeFunctionRedecl(Context& context,
|
||||
|
||||
// Check whether this is a redeclaration, merging if needed.
|
||||
static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
|
||||
SemIR::InstId prev_id,
|
||||
SemIR::InstId prev_id, SemIR::LocId name_loc_id,
|
||||
SemIR::FunctionDecl& function_decl,
|
||||
SemIR::Function& function_info, bool is_definition)
|
||||
-> void {
|
||||
@@ -179,7 +179,7 @@ static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
|
||||
}
|
||||
|
||||
if (!prev_function_id.has_value()) {
|
||||
DiagnoseDuplicateName(context, function_info.latest_decl_id(), prev_id);
|
||||
DiagnoseDuplicateName(context, name_loc_id, prev_id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,8 +295,9 @@ static auto BuildFunctionDecl(Context& context,
|
||||
DiagnosePoisonedName(context, name_context.poisoning_loc_id,
|
||||
name_context.loc_id);
|
||||
} else {
|
||||
TryMergeRedecl(context, node_id, name_context.prev_inst_id(), function_decl,
|
||||
function_info, is_definition);
|
||||
TryMergeRedecl(context, node_id, name_context.prev_inst_id(),
|
||||
name_context.loc_id, function_decl, function_info,
|
||||
is_definition);
|
||||
}
|
||||
|
||||
// Create a new function if this isn't a valid redeclaration.
|
||||
|
||||
Reference in New Issue
Block a user