diff --git a/compiler/gen/tests/test_gen.rs b/compiler/gen/tests/test_gen.rs index d020455b12..7c9532a0c8 100644 --- a/compiler/gen/tests/test_gen.rs +++ b/compiler/gen/tests/test_gen.rs @@ -614,22 +614,21 @@ mod test_gen { ); } - // doesn't work yet. The condition must be cast to an integer to use a jump table - // #[test] - // fn branch_third_float() { - // assert_evals_to!( - // indoc!( - // r#" - // when 10.0 is - // 1.0 -> 63 - // 2 -> 48 - // _ -> 112 - // "# - // ), - // 112.0, - // f64 - // ); - // } + #[test] + fn branch_third_float() { + assert_evals_to!( + indoc!( + r#" + when 10.0 is + 1.0 -> 63 + 2.0 -> 48 + _ -> 112 + "# + ), + 112, + i64 + ); + } #[test] fn branch_first_int() { @@ -1297,11 +1296,14 @@ mod test_gen { assert_evals_to!( indoc!( r#" - x : [ This Int, These Int Int ] + These a b : [ This a, That b, These a b ] + + x : These Int Int x = These 0x3 0x2 when x is These a b -> a + b + That v -> 8 This v -> v "# ), @@ -1331,6 +1333,26 @@ mod test_gen { ); } + // #[test] + // fn when_on_just_just() { + // assert_evals_to!( + // indoc!( + // r#" + // Maybe a : [ Nothing, Just a ] + // + // x : Maybe (Maybe a) + // x = Just (Just 41) + // + // when x is + // Just (Just v) -> v + 0x1 + // _ -> 0x1 + // "# + // ), + // 42, + // i64 + // ); + // } + // #[test] // fn linked_list_empty() { // assert_evals_to!( diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index f85df484e4..7e9cb052f8 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -156,7 +156,7 @@ fn flatten<'a>(path_pattern: (Path, Pattern<'a>), path_patterns: &mut Vec<(Path, // dearg (Can.PatternCtorArg _ _ pattern) = // pattern - todo!() + todo!("alternatives: {:?}", union.alternatives) } else { path_patterns.push(path_pattern); } @@ -911,7 +911,8 @@ fn decide_to_branching<'a>( Test::IsFloat(v) => v as u64, Test::IsBit(v) => v as u64, Test::IsByte { tag_id, .. } => tag_id as u64, - _ => todo!(), + Test::IsCtor { tag_id, .. } => tag_id as u64, + other => todo!("other {:?}", other), }; branches.push((tag, branch)); @@ -921,9 +922,7 @@ fn decide_to_branching<'a>( Expr::Switch { cond, cond_layout, - // branches: &'a [(u64, Expr<'a>)], branches: branches.into_bump_slice(), - // default_branch: &'a Expr<'a>, default_branch, ret_layout, }