mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:31:15 +01:00
Avoid witnesses in redecls when handling errors in handle_impl (#5409)
When we fill the witness table with errors, set the witness id to an error too, which signals to impl lookups to not use the impl. Make the use of the `Impl` from the store more consistent once it's been added to the store (or known to be there already).
This commit is contained in:
+12
-11
@@ -243,19 +243,20 @@ auto FinishImplWitness(Context& context, SemIR::ImplId impl_id) -> void {
|
||||
}
|
||||
|
||||
auto FillImplWitnessWithErrors(Context& context, SemIR::Impl& impl) -> void {
|
||||
if (impl.witness_id.has_value() &&
|
||||
impl.witness_id != SemIR::ErrorInst::InstId) {
|
||||
auto witness = context.insts().GetAs<SemIR::ImplWitness>(impl.witness_id);
|
||||
auto witness_table = context.insts().GetAs<SemIR::ImplWitnessTable>(
|
||||
witness.witness_table_id);
|
||||
auto witness_block =
|
||||
context.inst_blocks().GetMutable(witness_table.elements_id);
|
||||
for (auto& elem : witness_block) {
|
||||
if (elem == SemIR::ImplWitnessTablePlaceholder::TypeInstId) {
|
||||
elem = SemIR::ErrorInst::InstId;
|
||||
}
|
||||
if (impl.witness_id == SemIR::ErrorInst::InstId) {
|
||||
return;
|
||||
}
|
||||
auto witness = context.insts().GetAs<SemIR::ImplWitness>(impl.witness_id);
|
||||
auto witness_table =
|
||||
context.insts().GetAs<SemIR::ImplWitnessTable>(witness.witness_table_id);
|
||||
auto witness_block =
|
||||
context.inst_blocks().GetMutable(witness_table.elements_id);
|
||||
for (auto& elem : witness_block) {
|
||||
if (elem == SemIR::ImplWitnessTablePlaceholder::TypeInstId) {
|
||||
elem = SemIR::ErrorInst::InstId;
|
||||
}
|
||||
}
|
||||
impl.witness_id = SemIR::ErrorInst::InstId;
|
||||
}
|
||||
|
||||
auto AssignImplIdInWitness(Context& context, SemIR::ImplId impl_id,
|
||||
|
||||
Reference in New Issue
Block a user