Skip to content

Commit

Permalink
Fix bug introduced in #4613 (#4624)
Browse files Browse the repository at this point in the history
Issue was not properly handling `ImportRef` instructions in
`AddAssociatedEntities` in `check/import_ref.cpp`. Using `CARBON_CHECK`
instead of `CARBON_FATAL` was hiding the error.

---------

Co-authored-by: Josh L <[email protected]>
  • Loading branch information
josh11b and josh11b authored Dec 4, 2024
1 parent f8e7dad commit 6260f0f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions toolchain/check/import_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ static auto AddAssociatedEntities(ImportContext& context,
llvm::SmallVector<SemIR::InstId> new_associated_entities;
new_associated_entities.reserve(associated_entities.size());
for (auto inst_id : associated_entities) {
// Determine the name of the associated entity, by switching on its type.
// Determine the name of the associated entity, by switching on its kind.
SemIR::NameId import_name_id = SemIR::NameId::Invalid;
if (auto associated_const =
context.import_insts().TryGetAs<SemIR::AssociatedConstantDecl>(
Expand All @@ -1233,8 +1233,14 @@ static auto AddAssociatedEntities(ImportContext& context,
auto function =
context.import_functions().Get(function_decl->function_id);
import_name_id = function.name_id;
} else if (auto import_ref =
context.import_insts().TryGetAs<SemIR::AnyImportRef>(
inst_id)) {
import_name_id =
context.import_entity_names().Get(import_ref->entity_name_id).name_id;
} else {
CARBON_CHECK("Unhandled associated entity type");
CARBON_FATAL("Unhandled associated entity kind: {0}",
context.import_insts().Get(inst_id).kind());
}
auto name_id = GetLocalNameId(context, import_name_id);
auto entity_name_id = context.local_entity_names().Add(
Expand Down

0 comments on commit 6260f0f

Please sign in to comment.