Skip to content

Commit

Permalink
fix(type_checker): check function arguments length
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkeeyCat committed Oct 8, 2024
1 parent 91e95da commit f63ea6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/passes/type_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ impl TypeChecker {
.map(|expr| expr.type_(scope))
.collect::<std::result::Result<Vec<_>, _>>()?;

if symbol.parameters.len() != expr.arguments.len() {
return Err(ParserError::FunctionArguments(
fn_name.clone(),
symbol.parameters.to_owned(),
args_types,
));
}

for (expr, type_) in expr.arguments.iter().zip(&symbol.parameters) {
if let Err(_) = Self::check_assign(type_.to_owned(), expr, scope) {
return Err(ParserError::FunctionArguments(
Expand Down

0 comments on commit f63ea6d

Please sign in to comment.