From e71d4040717ab8a19e7e619596b733b0af8efcca Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 2 Nov 2018 19:54:04 -0700 Subject: [PATCH] Finished this refactor --- schala-lang/language/src/eval.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 7bb94ec..60e635b 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -373,8 +373,11 @@ impl<'a> State<'a> { let cond = self.expression(Node::Expr(cond))?; for alt in alternatives { // no matter what type of condition we have, ignore alternative if the guard evaluates false - if let Some(guard_expr) = alt.guard { - let guard_expr = guard_expr.clone().replace_conditional_target_sigil(&cond); + if let Some(ref guard_expr) = alt.guard { + let guard_expr = match &cond { + Node::Expr(ref e) => guard_expr.clone().replace_conditional_target_sigil(e), + _ => guard_expr.clone() + }; match self.expression(guard_expr.to_node())? { Node::Expr(Expr::Lit(::reduced_ast::Lit::Bool(true))) => (), _ => continue, @@ -382,8 +385,8 @@ impl<'a> State<'a> { } match cond { - Node::PrimObject { tag, items, .. } => { - if alt.tag.map(|t| t == tag).unwrap_or(true) { + Node::PrimObject { ref tag, ref items, .. } => { + if alt.tag.map(|t| t == *tag).unwrap_or(true) { let mut inner_state = State { values: self.values.new_scope(None), symbol_table_handle: self.symbol_table_handle.clone(), @@ -406,7 +409,7 @@ impl<'a> State<'a> { Node::PrimTuple { .. } => { return Err(format!("Prim tuple not done")) }, - Node::Expr(e) => { + Node::Expr(ref _e) => { if let None = alt.tag { return self.block(alt.item) }