From 3619008188c158f4345290bcfcf4688547504639 Mon Sep 17 00:00:00 2001 From: Kevin Xiao Date: Wed, 19 Jul 2023 16:18:03 -0400 Subject: [PATCH] Also decrement --- kalk/src/interpreter.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kalk/src/interpreter.rs b/kalk/src/interpreter.rs index 045019b..5d7a115 100644 --- a/kalk/src/interpreter.rs +++ b/kalk/src/interpreter.rs @@ -89,7 +89,6 @@ struct SumVar { } fn eval_stmt(context: &mut Context, stmt: &Stmt) -> Result { - context.recursion_depth += 1; match stmt { Stmt::VarDecl(_, _) => eval_var_decl_stmt(context, stmt), Stmt::FnDecl(_, _, _) => eval_fn_decl_stmt(), @@ -136,7 +135,10 @@ pub(crate) fn eval_expr( Expr::Boolean(value) => Ok(KalkValue::Boolean(*value)), Expr::Group(expr) => eval_group_expr(context, expr, unit), Expr::FnCall(identifier, expressions) => { - eval_fn_call_expr(context, identifier, expressions, unit) + context.recursion_depth += 1; + let res = eval_fn_call_expr(context, identifier, expressions, unit); + context.recursion_depth -= 1; + res } Expr::Piecewise(pieces) => eval_piecewise(context, pieces, unit), Expr::Vector(values) => eval_vector(context, values), @@ -517,6 +519,7 @@ pub(crate) fn eval_fn_call_expr( return Err(KalkError::StackOverflow); } + if arguments.len() != expressions.len() { return Err(KalkError::IncorrectAmountOfArguments( arguments.len(),