Tolerate incomplete interface when stringifying ImplWitnessAccess (#5730)

Closes #5727
This commit is contained in:
Geoff Romer
2025-06-26 14:37:16 +00:00
committed by GitHub
parent 78ef1678aa
commit 1893afe479
2 changed files with 33 additions and 8 deletions
+10 -8
View File
@@ -420,10 +420,15 @@ class Stringifier {
auto StringifyInst(InstId /*inst_id*/, ImplWitnessAccess inst) -> void {
auto witness_inst_id =
sem_ir_->constant_values().GetConstantInstId(inst.witness_id);
if (auto specific_interface =
TryGetSpecificInterfaceForImplWitness(witness_inst_id)) {
const auto& interface =
sem_ir_->interfaces().Get(specific_interface->interface_id);
auto lookup = sem_ir_->insts().GetAs<LookupImplWitness>(witness_inst_id);
auto specific_interface =
sem_ir_->specific_interfaces().Get(lookup.query_specific_interface_id);
const auto& interface =
sem_ir_->interfaces().Get(specific_interface.interface_id);
if (!interface.associated_entities_id.has_value()) {
step_stack_->Push(".(TODO: element ", inst.index, " in incomplete ",
witness_inst_id, ")");
} else {
auto entities =
sem_ir_->inst_blocks().Get(interface.associated_entities_id);
size_t index = inst.index.index;
@@ -446,11 +451,8 @@ class Stringifier {
}
step_stack_->Push(
".(",
StepStack::EntityNameItem{interface, specific_interface->specific_id},
StepStack::EntityNameItem{interface, specific_interface.specific_id},
".");
} else {
step_stack_->Push(".(TODO: element ", inst.index, " in ", witness_inst_id,
")");
}
if (auto lookup =