From d1c21e3fcd22a1bacdb5272af21d84ba4c6d47ad Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Wed, 17 Aug 2022 17:02:45 -0500 Subject: [PATCH] Add polymorphic expression reproduction cases from #1745 These work now that we have ways to compile polymorphic expressions. Closes #1745 --- crates/compiler/test_gen/src/gen_list.rs | 20 +++++++++++++++++ .../compiler/test_gen/src/gen_primitives.rs | 21 ++++++++++++++++++ crates/compiler/test_gen/src/gen_tags.rs | 22 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index 057750b461..c3540e619d 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -3369,3 +3369,23 @@ fn issue_3530_uninitialized_capacity_in_list_literal() { |(_, _, cap)| cap ); } + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn list_let_generalization() { + assert_evals_to!( + indoc!( + r#" + empty : List a + empty = [] + + xs : List Str + xs = List.append empty "foo" + + List.len xs + "# + ), + 1, + usize + ); +} diff --git a/crates/compiler/test_gen/src/gen_primitives.rs b/crates/compiler/test_gen/src/gen_primitives.rs index 8ed0dbc8bb..d986c46c19 100644 --- a/crates/compiler/test_gen/src/gen_primitives.rs +++ b/crates/compiler/test_gen/src/gen_primitives.rs @@ -4019,3 +4019,24 @@ fn mutually_recursive_captures() { RocStr ); } + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn int_let_generalization() { + assert_evals_to!( + indoc!( + r#" + manyAux : {} -> I32 + manyAux = \_ -> + output = \_ -> 42 + + output {} + + when manyAux {} is + _ -> "done" + "# + ), + RocStr::from("done"), + RocStr + ); +} diff --git a/crates/compiler/test_gen/src/gen_tags.rs b/crates/compiler/test_gen/src/gen_tags.rs index 2cad1617f8..6eccdd3bd1 100644 --- a/crates/compiler/test_gen/src/gen_tags.rs +++ b/crates/compiler/test_gen/src/gen_tags.rs @@ -1933,3 +1933,25 @@ fn issue_2165_recursive_tag_destructure() { RocStr ) } + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn tag_union_let_generalization() { + assert_evals_to!( + indoc!( + r#" + manyAux : {} -> [ Loop, Done ] + manyAux = \_ -> + output = Done + + output + + when manyAux {} is + Loop -> "loop" + Done -> "done" + "# + ), + RocStr::from("done"), + RocStr + ); +}