Check return type as well
This commit is contained in:
parent
3f4b8569ea
commit
e3e0cd9f9f
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user