From 3e7c7a50b4d10cb65bde3f34d60b06ba8917154b Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 26 Feb 2018 19:57:46 -0800 Subject: [PATCH] Move some code around --- src/schala_lang/eval.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 485ead8..8c0b102 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -156,16 +156,14 @@ impl<'a> State<'a> { Expression(Value(identifier), _) => { match self.values.get(&identifier) { Some(&ValueEntry::Function { ref body, ref param_names }) => { - let mut new_state = State::new_with_parent(self); - let sub_ast = body.clone(); - if arguments.len() != param_names.len() { return Err(format!("Wrong number of arguments for the function")); } + let mut new_state = State::new_with_parent(self); + let sub_ast = body.clone(); for (param, val) in param_names.iter().zip(arguments.into_iter()) { new_state.values.insert(param.clone(), ValueEntry::Binding { val }); } - let mut ret: Option = None; for statement in sub_ast.into_iter() { ret = new_state.eval_statement(statement)?;