List.keepIf must consume its list argument

This commit is contained in:
Folkert 2021-01-02 23:17:50 +01:00
parent 2ac19fb6e3
commit 981a84ccee
2 changed files with 14 additions and 1 deletions

View file

@ -2731,7 +2731,16 @@ fn run_low_level<'a, 'ctx, 'env>(
let inplace = get_inplace_from_layout(layout);
list_keep_if(env, inplace, parent, func, func_layout, list, list_layout)
list_keep_if(
env,
layout_ids,
inplace,
parent,
func,
func_layout,
list,
list_layout,
)
}
ListContains => {
// List.contains : List elem, elem -> Bool

View file

@ -1113,6 +1113,7 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
/// List.keepIf : List elem, (elem -> Bool) -> List elem
pub fn list_keep_if<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout_ids: &mut LayoutIds<'a>,
output_inplace: InPlace,
parent: FunctionValue<'ctx>,
func: BasicValueEnum<'ctx>,
@ -1212,6 +1213,9 @@ pub fn list_keep_if<'a, 'ctx, 'env>(
builder.position_at_end(cont_block);
// consume the input list
decrement_refcount_layout(env, parent, layout_ids, list, list_layout);
builder.build_load(result, "load_result")
}
}