don't pass closure argument if not expected

This commit is contained in:
Folkert 2021-09-17 22:51:51 +02:00
parent c68689a52b
commit 7416cc4e81
3 changed files with 52 additions and 3 deletions

View file

@ -2790,6 +2790,9 @@ fn mix_function_and_closure() {
r#"
app "test" provides [ main ] to "./platform"
# foo does not capture any variables
# but through unification will get a lambda set that does store information
# we must handle that correctly
foo = \x -> x
bar = \y -> \_ -> y
@ -2803,3 +2806,26 @@ fn mix_function_and_closure() {
RocStr
);
}
#[test]
fn mix_function_and_closure_level_of_indirection() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ main ] to "./platform"
foo = \x -> x
bar = \y -> \_ -> y
f = (if 1 == 1 then foo else (bar "nope nope nope"))
main : Str
main =
f "hello world"
"#
),
RocStr::from_slice(b"hello world"),
RocStr
);
}