Skip to content

Commit

Permalink
fix(type_checker): check each function's argument
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkeeyCat committed Oct 13, 2024
1 parent 27137f2 commit 7502d61
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/passes/type_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::Pass;
use crate::{
parser::{BinOp, Block, Expr, ExprBinary, Expression, ParserError, Stmt, UnOp},
scope::Scope,
symbol_table::SymbolTableError,
type_table::{self as tt, TypeTable},
types::{Type, TypeError, UintType},
};
Expand Down Expand Up @@ -115,7 +116,11 @@ impl TypeChecker {
Type::cast(expr.expr.type_(&scope)?, expr.type_.clone())?;
}
Expr::Lit(_) => (),
Expr::Ident(expr) => (),
Expr::Ident(expr) => {
scope.find_symbol(&expr.0).ok_or(ParserError::SymbolTable(
SymbolTableError::NotFound(expr.0.clone()),
))?;
}
Expr::Struct(expr) => {
Self::check_type(&expr.type_(scope)?, scope)?;

Expand All @@ -140,6 +145,10 @@ impl TypeChecker {
Expr::StructMethod(expr) => (),
Expr::ArrayAccess(expr) => (),
Expr::FunctionCall(expr) => {
for expr in &expr.arguments {
Self::check_expr(expr, scope)?;
}

let fn_name = &expr.name;
let symbol = scope.find_symbol(&expr.name).unwrap().function_unchecked();
let args_types = expr
Expand Down

0 comments on commit 7502d61

Please sign in to comment.