From 5eb647d448f09a228e45f57349a110a6d7cafb42 Mon Sep 17 00:00:00 2001 From: minneelyyyy Date: Wed, 16 Oct 2024 16:44:12 -0400 Subject: [PATCH] insert arguments into local space --- src/parser.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index caa68b7..7f37b00 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -184,6 +184,16 @@ impl ParseTree { // recursion requires that f's prototype is present in locals locals.insert(f.name.clone().unwrap(), f.clone()); + // we also need any function aprameters in local scope + for (name, t) in std::iter::zip(f.arg_names.clone().unwrap(), f.t.1.clone()) { + match t { + Type::Function(t) => { + locals.insert(name.clone(), Function::named(&name, t, None, None)); + } + _ => (), + } + } + f.body = Some(Box::new(ParseTree::parse(tokens, globals, &mut Cow::Borrowed(&locals))?)); assert!(f.body.is_some());