mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
represent byte/bool closure as unit
This commit is contained in:
parent
3ea63ee18f
commit
2c1ab68ea7
2 changed files with 28 additions and 6 deletions
|
@ -415,13 +415,10 @@ impl<'a> LambdaSet<'a> {
|
||||||
use UnionVariant::*;
|
use UnionVariant::*;
|
||||||
match variant {
|
match variant {
|
||||||
Never => Layout::Union(UnionLayout::NonRecursive(&[])),
|
Never => Layout::Union(UnionLayout::NonRecursive(&[])),
|
||||||
Unit | UnitWithArguments => Layout::Struct(&[]),
|
Unit | UnitWithArguments | BoolUnion { .. } | ByteUnion(_) => {
|
||||||
BoolUnion { .. } => {
|
// no useful information to store
|
||||||
// Layout::Builtin(Builtin::Int1),
|
|
||||||
|
|
||||||
Layout::Struct(&[])
|
Layout::Struct(&[])
|
||||||
}
|
}
|
||||||
ByteUnion(_) => Layout::Builtin(Builtin::Int8),
|
|
||||||
Newtype {
|
Newtype {
|
||||||
arguments: layouts, ..
|
arguments: layouts, ..
|
||||||
} => Layout::Struct(layouts.into_bump_slice()),
|
} => Layout::Struct(layouts.into_bump_slice()),
|
||||||
|
|
|
@ -2554,7 +2554,7 @@ fn mirror_llvm_alignment_padding() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn code_gen_unified_closure() {
|
fn lambda_set_bool() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
|
@ -2576,3 +2576,28 @@ fn code_gen_unified_closure() {
|
||||||
i64
|
i64
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn lambda_set_byte() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [ main ] to "./platform"
|
||||||
|
|
||||||
|
p1 = (\u -> u == 97)
|
||||||
|
p2 = (\u -> u == 98)
|
||||||
|
p3 = (\u -> u == 99)
|
||||||
|
|
||||||
|
main : I64
|
||||||
|
main =
|
||||||
|
oneOfResult = List.map [p1, p2, p3] (\p -> p 42)
|
||||||
|
|
||||||
|
when oneOfResult is
|
||||||
|
_ -> 32
|
||||||
|
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
32,
|
||||||
|
i64
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue