Type check arrow type expressions

This commit is contained in:
Sam Vervaeck 2024-07-11 16:39:19 +02:00
parent 9578e5d252
commit c8ceff3210
Signed by: samvv
SSH key fingerprint: SHA256:dIg0ywU1OP+ZYifrYxy8c5esO72cIKB+4/9wkZj1VaY

View file

@ -336,6 +336,19 @@ std::tuple<ConstraintSet, Type*> Checker::inferTypeExpr(TypeEnv& Env, TypeExpres
break;
}
case NodeKind::ArrowTypeExpression:
{
auto Arrow = static_cast<ArrowTypeExpression*>(TE);
auto [ReturnOut, ReturnTy] = inferTypeExpr(Env, Arrow->ReturnType);
Ty = ReturnTy;
for (auto PT: Arrow->ParamTypes) {
auto [ParamOut, ParamTy] = inferTypeExpr(Env, PT);
mergeTo(Out, ParamOut);
Ty = new TFun(ParamTy, Ty);
}
break;
}
default:
ZEN_UNREACHABLE