diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index 9d522c7e01..679feb7997 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -228,13 +228,13 @@ fn to_decision_tree(raw_branches: Vec) -> DecisionTree { // get the `_decision_tree` without cloning decision_edges.pop().unwrap().1 } - (_, []) => helper(path, decision_edges, None), + (_, []) => break_out_guard(path, decision_edges, None), ([], _) => { // should be guaranteed by the patterns debug_assert!(!fallback.is_empty()); to_decision_tree(fallback) } - (_, _) => helper( + (_, _) => break_out_guard( path, decision_edges, Some(Box::new(to_decision_tree(fallback))), @@ -244,7 +244,8 @@ fn to_decision_tree(raw_branches: Vec) -> DecisionTree { } } -fn helper<'a>( +/// Give a guard it's own Decision +fn break_out_guard<'a>( path: Vec, mut edges: Vec<(GuardedTest<'a>, DecisionTree<'a>)>, default: Option>>, @@ -261,7 +262,7 @@ fn helper<'a>( Some(index) => { let (a, b) = edges.split_at_mut(index + 1); - let new_default = helper(path.clone(), b.to_vec(), default); + let new_default = break_out_guard(path.clone(), b.to_vec(), default); let mut left = a.to_vec(); let guard = left.pop().unwrap(); diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 364dafcbdf..4f0d18b4bf 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -5098,6 +5098,8 @@ fn from_can_when<'a>( let new_guard_stmt = store_pattern(env, procs, layout_cache, &pattern, cond_symbol, guard_stmt); + + dbg!(symbol); ( pattern, Guard::Guard { diff --git a/compiler/test_gen/src/gen_tags.rs b/compiler/test_gen/src/gen_tags.rs index 40e5403914..ccbfa75b45 100644 --- a/compiler/test_gen/src/gen_tags.rs +++ b/compiler/test_gen/src/gen_tags.rs @@ -510,8 +510,8 @@ fn if_guard_multiple() { f = \n -> when Identity n 0 is Identity x _ if x == 0 -> x + 0 - Identity x _ if x == 1 -> x + 0 - Identity x _ if x == 2 -> x + 0 + # Identity x _ if x == 1 -> x + 0 + # Identity x _ if x == 2 -> x + 0 Identity x _ -> x - x { a: f 0, b: f 1, c: f 2, d: f 4 }