mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Fixed inplace problem in list_set
This commit is contained in:
parent
9351746952
commit
30b7545da0
2 changed files with 12 additions and 5 deletions
|
@ -1877,6 +1877,8 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
ListSetInPlace => {
|
||||
let (list_symbol, list_layout) = load_symbol_and_layout(env, scope, &args[0]);
|
||||
|
||||
let output_inplace = get_inplace_from_layout(layout);
|
||||
|
||||
list_set(
|
||||
parent,
|
||||
&[
|
||||
|
@ -1886,6 +1888,7 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
],
|
||||
env,
|
||||
InPlace::InPlace,
|
||||
output_inplace,
|
||||
)
|
||||
}
|
||||
ListSet => {
|
||||
|
@ -1897,8 +1900,10 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
(load_symbol_and_layout(env, scope, &args[2])),
|
||||
];
|
||||
|
||||
let in_place = || list_set(parent, arguments, env, InPlace::InPlace);
|
||||
let clone = || list_set(parent, arguments, env, InPlace::Clone);
|
||||
let output_inplace = get_inplace_from_layout(layout);
|
||||
|
||||
let in_place = || list_set(parent, arguments, env, InPlace::InPlace, output_inplace);
|
||||
let clone = || list_set(parent, arguments, env, InPlace::Clone, output_inplace);
|
||||
let empty = || list_symbol;
|
||||
|
||||
maybe_inplace_list(
|
||||
|
|
|
@ -642,7 +642,8 @@ pub fn list_set<'a, 'ctx, 'env>(
|
|||
parent: FunctionValue<'ctx>,
|
||||
args: &[(BasicValueEnum<'ctx>, &'a Layout<'a>)],
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
inplace: InPlace,
|
||||
input_inplace: InPlace,
|
||||
output_inplace: InPlace,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let builder = env.builder;
|
||||
|
||||
|
@ -664,14 +665,15 @@ pub fn list_set<'a, 'ctx, 'env>(
|
|||
let ctx = env.context;
|
||||
let elem_type = basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes);
|
||||
let ptr_type = get_ptr_type(&elem_type, AddressSpace::Generic);
|
||||
let (new_wrapper, array_data_ptr) = match inplace {
|
||||
|
||||
let (new_wrapper, array_data_ptr) = match input_inplace {
|
||||
InPlace::InPlace => (
|
||||
original_wrapper,
|
||||
load_list_ptr(builder, original_wrapper, ptr_type),
|
||||
),
|
||||
InPlace::Clone => clone_nonempty_list(
|
||||
env,
|
||||
inplace,
|
||||
output_inplace,
|
||||
list_len,
|
||||
load_list_ptr(builder, original_wrapper, ptr_type),
|
||||
elem_layout,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue