Add rest of typechecking
This commit is contained in:
parent
8314fe2b61
commit
4baeaff705
@ -99,6 +99,9 @@ namespace AST {
|
||||
if (binop) {
|
||||
return binop->result;
|
||||
}
|
||||
|
||||
// TODO check for binops that may be implicitly castable
|
||||
|
||||
state.errors.push_back(CompileError(
|
||||
"No suitable binop between "
|
||||
+ lhs_ty->formatted() + " "
|
||||
@ -170,10 +173,12 @@ namespace AST {
|
||||
}
|
||||
|
||||
void IfStatement::typecheck(typecheck::State& state, typecheck::Scope& scope) {
|
||||
auto bool_ty_ptr = new types::FundamentalType{ types::FundamentalTypeKind::Bool };
|
||||
this->m_condition->typecheck(state, scope, std::shared_ptr<types::Type>{ bool_ty_ptr });
|
||||
auto bool_ty = std::shared_ptr<types::Type>{
|
||||
new types::FundamentalType{ types::FundamentalTypeKind::Bool } };
|
||||
auto expr_ty = this->m_condition->typecheck(state, scope, bool_ty);
|
||||
|
||||
// TODO check that condition really is a boolean
|
||||
auto check_res = check_type(expr_ty, bool_ty);
|
||||
this->m_condition = handle_res(std::move(this->m_condition), check_res, state);
|
||||
|
||||
this->m_then->typecheck(state, scope);
|
||||
if (this->m_else) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user