mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Don't substitute into the targeted instructions of an associated constant. (#4342)
When an instruction makes an absolute reference to another instruction, such as when `assoc_const` refers to the declaration of the associated constant in an interface, substitution into that instruction should not substitute into the referenced instruction. Mark the corresponding `InstId` fields in the typed instructions as being absolute by giving them a distinct ID type that `Subst` doesn't substitute into. This formation of unnecessarily complicated SemIR that could in some cases lead to a CHECK failure when printing formatted SemIR because the same instruction ends up in multiple scopes.
This commit is contained in:
@@ -1030,6 +1030,10 @@ class FormatterImpl {
|
||||
out_ << inst_namer_->GetNameFor(scope_, id);
|
||||
}
|
||||
|
||||
auto FormatName(AbsoluteInstId id) -> void {
|
||||
FormatName(static_cast<InstId>(id));
|
||||
}
|
||||
|
||||
auto FormatName(SpecificId id) -> void {
|
||||
const auto& specific = sem_ir_.specifics().Get(id);
|
||||
FormatName(specific.generic_id);
|
||||
|
||||
Reference in New Issue
Block a user