mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
make List.map borrow based on passed function
This commit is contained in:
parent
3a4a78fdbb
commit
3ca6ffade9
8 changed files with 106 additions and 35 deletions
|
@ -2287,14 +2287,30 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
DecRef(symbol) => {
|
||||
let (value, layout) = load_symbol_and_layout(scope, symbol);
|
||||
|
||||
if layout.is_refcounted() {
|
||||
if value.is_pointer_value() {
|
||||
// BasicValueEnum::PointerValue(value_ptr) => {
|
||||
let value_ptr = value.into_pointer_value();
|
||||
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
match layout {
|
||||
Layout::Builtin(Builtin::List(_, _)) => {
|
||||
debug_assert!(value.is_struct_value());
|
||||
|
||||
let refcount_ptr = PointerToRefcount::from_list_wrapper(
|
||||
env,
|
||||
value.into_struct_value(),
|
||||
);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
} else {
|
||||
eprint!("we're likely leaking memory; see issue #985 for details");
|
||||
}
|
||||
|
||||
_ if layout.is_refcounted() => {
|
||||
if value.is_pointer_value() {
|
||||
// BasicValueEnum::PointerValue(value_ptr) => {
|
||||
let value_ptr = value.into_pointer_value();
|
||||
let refcount_ptr =
|
||||
PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
} else {
|
||||
eprint!("we're likely leaking memory; see issue #985 for details");
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue