represent empty closure as unit (not void)

This commit is contained in:
Folkert 2021-09-24 15:41:00 +02:00
parent 1fba3702a8
commit f43c10373f
2 changed files with 29 additions and 1 deletions

View file

@ -2031,3 +2031,31 @@ fn map_with_index_multi_record() {
RocList<((), ())>
);
}
#[test]
fn empty_list_of_function_type() {
// see https://github.com/rtfeldman/roc/issues/1732
assert_evals_to!(
indoc!(
r#"
myList : List (Str -> Str)
myList = []
myClosure : Str -> Str
myClosure = \_ -> "bar"
choose =
if False then
myList
else
[ myClosure ]
when List.get choose 0 is
Ok f -> f "foo"
Err _ -> "bad!"
"#
),
RocStr::from_slice(b"bar"),
RocStr
);
}