Forbid nested where inside a where expression (#7378)

This disallows building a facet type that contains another facet type
with non-extend constraints in it. Which in turn prevents the
possibility of introducing a different `.Self` into a facet type.

Eval can still insert a facet type with non-extend constraints, as we
only prevent it for `where` being written into the facet type. There is
a TODO in handle_where.cpp for this and some tests in
toolchain/check/testdata/facet/nested_facet_types_from_eval.carbon
This commit is contained in:
Dana Jansens
2026-06-25 18:56:36 +00:00
committed by GitHub
parent 093dc04db6
commit b22ee48c9b
19 changed files with 671 additions and 1151 deletions
+4
View File
@@ -3243,6 +3243,10 @@ auto TryEvalTypedInst<SemIR::WhereExpr>(EvalContext& eval_context,
Phase phase = Phase::Concrete;
SemIR::FacetTypeInfo info;
if (inst.type_id() == SemIR::ErrorInst::TypeId) {
return SemIR::ErrorInst::ConstantId;
}
// Note that these requirement instructions don't have a constant value. That
// means we have to look for errors inside them, we can't just look to see if
// their constant value is an error.