Finished this refactor

This commit is contained in:
greg 2018-11-02 19:54:04 -07:00
parent cab4702bd6
commit e71d404071
1 changed files with 8 additions and 5 deletions

View File

@ -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)
}