mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
represent empty closure as unit (not void)
This commit is contained in:
parent
1fba3702a8
commit
f43c10373f
2 changed files with 29 additions and 1 deletions
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue