Fix binops not using hint properly

This commit is contained in:
Sofia 2025-07-22 22:34:07 +03:00
parent ef427f5e58
commit 8bbee5eb41
3 changed files with 5 additions and 1 deletions

View File

@ -385,10 +385,12 @@ impl Builder {
}
Instr::FunctionCall(fun, params) => {
let param_types = self.function_data(&fun).params;
dbg!(&params, &param_types);
if param_types.len() != params.len() {
return Err(()); // TODO error: invalid amount of params
}
for (a, b) in param_types.iter().zip(params) {
dbg!(b.get_type(&self)?);
if *a != b.get_type(&self)? {
return Err(()); // TODO error: params do not match
}

View File

@ -408,7 +408,7 @@ impl Expression {
ExprKind::BinOp(op, lhs, rhs) => {
// TODO make sure lhs and rhs can actually do this binary
// operation once relevant
let lhs_res = lhs.typecheck(state, &typerefs, None);
let lhs_res = lhs.typecheck(state, &typerefs, hint_t);
let lhs_type = state.or_else(lhs_res, TypeKind::Vague(Vague::Unknown), lhs.1);
let rhs_res = rhs.typecheck(state, &typerefs, Some(&lhs_type));
let rhs_type = state.or_else(rhs_res, TypeKind::Vague(Vague::Unknown), rhs.1);

View File

@ -1,3 +1,5 @@
struct SDL_Thing {}
extern fn SDL_malloc(size: u64) -> *SDL_Thing;
fn main() {