insert arguments into local space

This commit is contained in:
2024-10-16 16:44:12 -04:00
parent 7b01ac45fc
commit 5eb647d448

View File

@@ -184,6 +184,16 @@ impl ParseTree {
// recursion requires that f's prototype is present in locals // recursion requires that f's prototype is present in locals
locals.insert(f.name.clone().unwrap(), f.clone()); 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))?)); f.body = Some(Box::new(ParseTree::parse(tokens, globals, &mut Cow::Borrowed(&locals))?));
assert!(f.body.is_some()); assert!(f.body.is_some());