diff --git a/src/ir/expr.rs b/src/ir/expr.rs index 8a9f531..bab0d9e 100644 --- a/src/ir/expr.rs +++ b/src/ir/expr.rs @@ -251,12 +251,16 @@ pub fn get_last_ident(exprs: &LinkedList) -> Option { } pub fn evaluate(exprs: LinkedList, bindings: &ValueBindings) -> evaluation::Result { - let bindings = bindings.nested_scope(); if exprs.iter().all(|e| !e.isnt_noop()) { bindings.lookup(&exprs.back().ok_or(EvaluateError::EvaluatingZeroLengthExpr)?.identifier) .ok_or_else(|| EvaluateError::UndefinedValue(exprs.back().unwrap().identifier.clone())) .cloned() + } else if exprs.len() == 1 { + exprs.back() + .unwrap() + .evaluate(&bindings) } else { + let bindings = bindings.nested_scope(); let (all_bindings, last_ident) = exprs.into_iter() .filter(Expr::isnt_noop) .try_fold(