From 3f4b8569eab1819f447f32f1ec23ab98bb0c357c Mon Sep 17 00:00:00 2001 From: Sofia Date: Mon, 13 Apr 2026 17:23:53 +0300 Subject: [PATCH] Fix bug with parameter typechecking --- src/typechecker.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/typechecker.cpp b/src/typechecker.cpp index 46130c8..188bc16 100644 --- a/src/typechecker.cpp +++ b/src/typechecker.cpp @@ -113,12 +113,17 @@ namespace AST { state.errors.push_back(CompileError("too many arguments", this->m_meta)); } else { - for (int i = 0; i < static_cast(fn_ty->m_param_tys.size()); i++) { - auto expected_param_ty = fn_ty->m_param_tys[i]; - auto param_ty = this->m_args[i]->typecheck(state, scope, expected_param_ty); + for (int i = 0; i < static_cast(this->m_args.size()); i++) { + if (i < static_cast(fn_ty->m_param_tys.size())) { + auto expected_param_ty = fn_ty->m_param_tys[i]; + auto param_ty = this->m_args[i]->typecheck(state, scope, 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); + 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); + } + else { + this->m_args[i]->typecheck(state, scope, {}); + } } }