mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 03:12:20 +00:00
fix incorrect element width used for List.append in dev backend
This commit is contained in:
parent
685025a240
commit
bd0cb6338e
2 changed files with 29 additions and 1 deletions
|
@ -2949,7 +2949,11 @@ impl<
|
|||
self.load_layout_alignment(list_layout, Symbol::DEV_TMP);
|
||||
|
||||
// Load element_width argument (usize).
|
||||
self.load_layout_stack_size(*ret_layout, Symbol::DEV_TMP2);
|
||||
let element_layout = match self.interner().get_repr(*ret_layout) {
|
||||
LayoutRepr::Builtin(Builtin::List(e)) => e,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
self.load_layout_stack_size(element_layout, Symbol::DEV_TMP2);
|
||||
|
||||
// Load UpdateMode.Immutable argument (0u8)
|
||||
let u8_layout = Layout::U8;
|
||||
|
|
|
@ -821,6 +821,30 @@ fn list_append_longer_list() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn list_append_record() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
[
|
||||
{ name: "foo", content: "cfoo" },
|
||||
{ name: "bar", content: "cbar" },
|
||||
{ name: "baz", content: "cbaz" },
|
||||
]
|
||||
|> List.append { name: "spam", content: "cspam" }
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[
|
||||
(RocStr::from("cfoo"), RocStr::from("foo"),),
|
||||
(RocStr::from("cbar"), RocStr::from("bar"),),
|
||||
(RocStr::from("cbaz"), RocStr::from("baz"),),
|
||||
(RocStr::from("cspam"), RocStr::from("spam"),),
|
||||
]),
|
||||
RocList<(RocStr, RocStr)>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn list_prepend() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue