mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
List.keepIf must consume its list argument
This commit is contained in:
parent
2ac19fb6e3
commit
981a84ccee
2 changed files with 14 additions and 1 deletions
|
@ -2731,7 +2731,16 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let inplace = get_inplace_from_layout(layout);
|
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 => {
|
ListContains => {
|
||||||
// List.contains : List elem, elem -> Bool
|
// List.contains : List elem, elem -> Bool
|
||||||
|
|
|
@ -1113,6 +1113,7 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
|
||||||
/// List.keepIf : List elem, (elem -> Bool) -> List elem
|
/// List.keepIf : List elem, (elem -> Bool) -> List elem
|
||||||
pub fn list_keep_if<'a, 'ctx, 'env>(
|
pub fn list_keep_if<'a, 'ctx, 'env>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env>,
|
||||||
|
layout_ids: &mut LayoutIds<'a>,
|
||||||
output_inplace: InPlace,
|
output_inplace: InPlace,
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
func: BasicValueEnum<'ctx>,
|
func: BasicValueEnum<'ctx>,
|
||||||
|
@ -1212,6 +1213,9 @@ pub fn list_keep_if<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
builder.position_at_end(cont_block);
|
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")
|
builder.build_load(result, "load_result")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue