fix function calls with no argument

This commit is contained in:
Aidan Hahn 2021-11-02 19:18:11 -07:00
parent ee3b53bfb5
commit d8eef9c95b
No known key found for this signature in database
GPG key ID: 327711E983899316

View file

@ -46,14 +46,22 @@ pub fn eval(
// another check to detect if we may have a function call // another check to detect if we may have a function call
if let Ctr::Symbol(ref tok) = car { if let Ctr::Symbol(ref tok) = car {
if let Ctr::Seg(ast) = cdr { match cdr {
Ctr::Seg(ast) => {
if let Some(func) = funcs.borrow().get(tok) { if let Some(func) = funcs.borrow().get(tok) {
return func_call(func.clone(), ast.clone(), vars.clone(), funcs.clone()) return func_call(func.clone(), ast.clone(), vars.clone(), funcs.clone())
} else { } else {
return Err(format!("Couldnt find function: {}.", tok)) return Err(format!("Couldnt find function: {}.", tok))
} }
},
Ctr::None => {
if let Some(func) = funcs.borrow().get(tok) {
return func_call(func.clone(), new_ast(Ctr::None, Ctr::None), vars.clone(), funcs.clone())
} else { } else {
return Err(format!("Arguments to function not a list!")) return Err(format!("Couldnt find function: {}.", tok))
}
},
_ => return Err(format!("Arguments to function not a list!"))
} }
} }