Fix bug with parameter typechecking
This commit is contained in:
parent
185f25d412
commit
3f4b8569ea
@ -113,13 +113,18 @@ namespace AST {
|
|||||||
state.errors.push_back(CompileError("too many arguments", this->m_meta));
|
state.errors.push_back(CompileError("too many arguments", this->m_meta));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < static_cast<int>(fn_ty->m_param_tys.size()); i++) {
|
for (int i = 0; i < static_cast<int>(this->m_args.size()); i++) {
|
||||||
|
if (i < static_cast<int>(fn_ty->m_param_tys.size())) {
|
||||||
auto expected_param_ty = fn_ty->m_param_tys[i];
|
auto expected_param_ty = fn_ty->m_param_tys[i];
|
||||||
auto param_ty = this->m_args[i]->typecheck(state, scope, expected_param_ty);
|
auto param_ty = this->m_args[i]->typecheck(state, scope, expected_param_ty);
|
||||||
|
|
||||||
auto check_res = check_type(param_ty, expected_param_ty);
|
auto check_res = check_type(param_ty, expected_param_ty);
|
||||||
this->m_args[i] = handle_res(std::move(this->m_args[i]), check_res, state);
|
this->m_args[i] = handle_res(std::move(this->m_args[i]), check_res, state);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this->m_args[i]->typecheck(state, scope, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fn_ty->m_ret_ty;
|
return fn_ty->m_ret_ty;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user