Also decrement

This commit is contained in:
Kevin Xiao 2023-07-19 16:18:03 -04:00
parent 3e14a747fd
commit 3619008188
No known key found for this signature in database

View File

@ -89,7 +89,6 @@ struct SumVar {
}
fn eval_stmt(context: &mut Context, stmt: &Stmt) -> Result<KalkValue, KalkError> {
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(),