Initial support for where expressions. (#1310)

Build constraint types from `where` expressions. This is very bare-bones; there's no support for constraining `.Self` or associated types yet, but degenerate cases not involving self-reference work.

`==` constraints are syntactically supported but not semantically verified yet, and they aren't used for anything.
This commit is contained in:
Richard Smith
2022-06-09 10:31:04 -07:00
committed by GitHub
parent 36b9d997b7
commit 9007b3952d
20 changed files with 677 additions and 78 deletions
+5
View File
@@ -412,6 +412,7 @@ auto Interpreter::StepLvalue() -> ErrorOr<Success> {
case ExpressionKind::ValueLiteral:
case ExpressionKind::IntrinsicExpression:
case ExpressionKind::IfExpression:
case ExpressionKind::WhereExpression:
case ExpressionKind::ArrayTypeLiteral:
case ExpressionKind::InstantiateImpl:
CARBON_FATAL() << "Can't treat expression as lvalue: " << exp;
@@ -1082,6 +1083,10 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
}
break;
}
case ExpressionKind::WhereExpression: {
return todo_.FinishAction(
&cast<TypeOfConstraintType>(exp.static_type()).constraint_type());
}
case ExpressionKind::UnimplementedExpression:
CARBON_FATAL() << "Unimplemented: " << exp;
case ExpressionKind::ArrayTypeLiteral: {