mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Merge branch 'main' into Frame-Limited
This commit is contained in:
commit
b0c1877a04
26 changed files with 448 additions and 193 deletions
|
@ -305,8 +305,8 @@ where
|
|||
debug_assert_eq!(variant_types.len(), 1);
|
||||
variant_types[0]
|
||||
} else {
|
||||
let data_type = builder.add_union_type(&variant_types)?;
|
||||
let cell_type = builder.add_heap_cell_type();
|
||||
let data_type = builder.add_union_type(&variant_types)?;
|
||||
|
||||
builder.add_tuple_type(&[cell_type, data_type])?
|
||||
};
|
||||
|
@ -1476,7 +1476,8 @@ fn expr_spec<'a>(
|
|||
|
||||
let _unit = builder.add_update(block, update_mode_var, heap_cell)?;
|
||||
|
||||
with_new_heap_cell(builder, block, union_data)
|
||||
let value = with_new_heap_cell(builder, block, union_data)?;
|
||||
builder.add_make_named(block, MOD_APP, type_name, value)
|
||||
}
|
||||
RuntimeErrorFunction(_) => {
|
||||
let type_id = layout_spec(env, builder, interner, layout)?;
|
||||
|
|
|
@ -4421,3 +4421,42 @@ fn layout_cache_structure_with_multiple_recursive_structures() {
|
|||
u8
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn reset_recursive_type_wraps_in_named_type() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r###"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main : Str
|
||||
main =
|
||||
newList = mapLinkedList (Cons 1 (Cons 2 (Cons 3 Nil))) (\x -> x + 1)
|
||||
printLinkedList newList Num.toStr
|
||||
|
||||
LinkedList a : [Cons a (LinkedList a), Nil]
|
||||
|
||||
mapLinkedList : LinkedList a, (a -> b) -> LinkedList b
|
||||
mapLinkedList = \linkedList, f -> when linkedList is
|
||||
Nil -> Nil
|
||||
Cons x xs ->
|
||||
s = if Bool.true then "true" else "false"
|
||||
expect s == "true"
|
||||
|
||||
Cons (f x) (mapLinkedList xs f)
|
||||
|
||||
printLinkedList : LinkedList a, (a -> Str) -> Str
|
||||
printLinkedList = \linkedList, f ->
|
||||
when linkedList is
|
||||
Nil -> "Nil"
|
||||
Cons x xs ->
|
||||
strX = f x
|
||||
strXs = printLinkedList xs f
|
||||
"Cons \(strX) (\(strXs))"
|
||||
"###
|
||||
),
|
||||
RocStr::from("Cons 2 (Cons 3 (Cons 4 (Nil)))"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue