where check stage, step 3: some type checking (#4364)

With this, we now check:

* The left argument to `where` is a facet type
* The right argument of a rewrite (`=`) requirement converts to the type
of the left argument.
* The left argument of an `impls` requirement is a type and the right
argument is a facet type.

No checking is done for `==` constraints yet.

In addition, make the "is facet type" query into its own function and
fix some comments noticed as part of this change.

This change reveals that accessing the members of a facet, like `.Self`,
isn't doing the right thing, and will have to be fixed in a follow-on
PR. Some tests have been adjusted or disabled as a result.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
This commit is contained in:
josh11b
2024-10-05 01:03:43 +00:00
committed by GitHub
co-authored by Josh L
parent 17411c5e78
commit 6dbeda612a
10 changed files with 1294 additions and 168 deletions
+1 -3
View File
@@ -1192,9 +1192,7 @@ auto Context::GetTypeIdForTypeConstant(SemIR::ConstantId constant_id)
auto type_id =
insts().Get(constant_values().GetInstId(constant_id)).type_id();
// TODO: For now, we allow values of facet type to be used as types.
CARBON_CHECK(type_id == SemIR::TypeId::TypeType ||
types().Is<SemIR::InterfaceType>(type_id) ||
constant_id == SemIR::ConstantId::Error,
CARBON_CHECK(IsFacetType(type_id) || constant_id == SemIR::ConstantId::Error,
"Forming type ID for non-type constant of type {0}",
types().GetAsInst(type_id));