Fix function recursion

This commit is contained in:
Jeff 2024-02-12 18:15:49 -05:00
parent bbab728ce9
commit 41a268389c
2 changed files with 5 additions and 3 deletions

View File

@ -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.

View File

@ -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)
}
}