Initial support for empty named constraints (#6245)

Type check named constraint decls and definitions. We don't correctly
error if you put a `fn` inside them. There is no support for `require`
or `alias` yet, so there's nothing useful you can do with them yet.

We have attempted to share code between `interface` and `constraint` as
they are quite similar. First by splitting out some of
handle_interface.cpp to a separate file. Second by sharing some code
paths when you want a facet type from either one, as they both turn into
a facet type.
This commit is contained in:
Dana Jansens
2025-10-22 18:26:32 +00:00
committed by GitHub
parent a340808062
commit 22580a47d3
41 changed files with 1771 additions and 142 deletions
+10
View File
@@ -437,6 +437,16 @@ class Stringifier {
">");
}
auto StringifyInst(InstId /*inst_id*/, GenericNamedConstraintType inst)
-> void {
const auto& constraint =
sem_ir_->named_constraints().Get(inst.named_constraint_id);
*out_ << "<type of ";
step_stack_->Push(StepStack::QualifiedNameItem{constraint.parent_scope_id,
constraint.name_id},
">");
}
// Determine the specific interface that an impl witness instruction provides
// an implementation of.
// TODO: Should we track this in the type?