mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +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
|
@ -599,7 +599,7 @@ impl<'a> LambdaSet<'a> {
|
||||||
// this can happen when there is a type error somewhere
|
// this can happen when there is a type error somewhere
|
||||||
Ok(LambdaSet {
|
Ok(LambdaSet {
|
||||||
set: &[],
|
set: &[],
|
||||||
representation: arena.alloc(Layout::Union(UnionLayout::NonRecursive(&[]))),
|
representation: arena.alloc(Layout::Struct(&[])),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => panic!("called LambdaSet.from_var on invalid input"),
|
_ => panic!("called LambdaSet.from_var on invalid input"),
|
||||||
|
|
|
@ -2031,3 +2031,31 @@ fn map_with_index_multi_record() {
|
||||||
RocList<((), ())>
|
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