From 41a268389c6068281228e4d0bedc13e80e310ebe Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 12 Feb 2024 18:15:49 -0500 Subject: [PATCH] Fix function recursion --- src/abstract_tree/assignment.rs | 4 ++-- src/abstract_tree/function_call.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/abstract_tree/assignment.rs b/src/abstract_tree/assignment.rs index a08575a..017f60c 100644 --- a/src/abstract_tree/assignment.rs +++ b/src/abstract_tree/assignment.rs @@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize}; use crate::{ context::Context, error::{RuntimeError, SyntaxError, ValidationError}, - AbstractTree, AssignmentOperator, Format, Identifier, SourcePosition, Statement, SyntaxNode, - Type, TypeSpecification, Value, + AbstractTree, AssignmentOperator, Format, Function, Identifier, SourcePosition, Statement, + SyntaxNode, Type, TypeSpecification, Value, }; /// Variable assignment, including add-assign and subtract-assign operations. diff --git a/src/abstract_tree/function_call.rs b/src/abstract_tree/function_call.rs index 8d8cf83..80c3052 100644 --- a/src/abstract_tree/function_call.rs +++ b/src/abstract_tree/function_call.rs @@ -137,6 +137,8 @@ impl AbstractTree for FunctionCall { let key = identifier.inner(); if let Some(value) = context.get_value(key)? { + self.context + .set_value(identifier.inner().clone(), value.clone())?; value.clone() } else { return Err(RuntimeError::VariableIdentifierNotFound( @@ -163,7 +165,7 @@ impl AbstractTree for FunctionCall { self.context.set_value(identifier.inner().clone(), value)?; } - value.as_function()?.call(&[], source, context) + function.call(&[], source, &self.context) } }