Check return type as well

This commit is contained in:
Sofia 2026-04-13 17:25:36 +03:00
parent 3f4b8569ea
commit e3e0cd9f9f

View File

@ -131,8 +131,11 @@ namespace AST {
}
void ReturnStatement::typecheck(typecheck::State& state, typecheck::Scope& scope) {
this->m_expr->typecheck(state, scope, scope.return_ty);
// TODO make sure returned type matches function return type.
auto res_ty = this->m_expr->typecheck(state, scope, scope.return_ty);
if (scope.return_ty) {
auto check_res = check_type(res_ty, *scope.return_ty);
this->m_expr = handle_res(std::move(this->m_expr), check_res, state);
}
}
void InitializationStatement::typecheck(typecheck::State& state, typecheck::Scope& scope) {