mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
fix dev-wasm ListGetUnsafe refcounting
This commit is contained in:
parent
5d613cd5f5
commit
0d083bc192
2 changed files with 20 additions and 7 deletions
|
@ -416,13 +416,6 @@ impl<'a> LowLevelCall<'a> {
|
||||||
AddressValue::NotLoaded(elem_local),
|
AddressValue::NotLoaded(elem_local),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Increment refcount
|
|
||||||
if self.ret_layout_raw.is_refcounted(backend.layout_interner) {
|
|
||||||
let inc_fn = backend.get_refcount_fn_index(self.ret_layout, HelperOp::Inc);
|
|
||||||
backend.code_builder.get_local(elem_local);
|
|
||||||
backend.code_builder.call(inc_fn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ListReplaceUnsafe => {
|
ListReplaceUnsafe => {
|
||||||
// List.replace_unsafe : List elem, U64, elem -> { list: List elem, value: elem }
|
// List.replace_unsafe : List elem, U64, elem -> { list: List elem, value: elem }
|
||||||
|
|
|
@ -179,6 +179,26 @@ fn list_str_slice() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "gen-wasm")]
|
||||||
|
fn list_get() {
|
||||||
|
assert_refcounts!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
s = Str.concat "A long enough string " "to be heap-allocated"
|
||||||
|
i1 = [s, s, s]
|
||||||
|
List.get i1 1
|
||||||
|
|> Result.withDefault ""
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr,
|
||||||
|
&[
|
||||||
|
(StandardRC, Live(1)), // s
|
||||||
|
(AfterSize, Deallocated), // i1
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "gen-wasm")]
|
#[cfg(feature = "gen-wasm")]
|
||||||
fn list_map() {
|
fn list_map() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue