mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 19:55:11 +00: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:
1 parent
1f268b5d8b
commit
90898a8e19
8 files changed
+96
-173
No files matched your search
+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