mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Fixed small errors in list push, such as using wrong argument, and using wrong list length
This commit is contained in:
parent
0531d91301
commit
4cf87d2374
1 changed files with 4 additions and 5 deletions
|
@ -1402,7 +1402,7 @@ fn call_with_args<'a, 'ctx, 'env>(
|
||||||
Symbol::FLOAT_ROUND => call_intrinsic(LLVM_LROUND_I64_F64, env, args),
|
Symbol::FLOAT_ROUND => call_intrinsic(LLVM_LROUND_I64_F64, env, args),
|
||||||
Symbol::LIST_SET => list_set(parent, args, env, InPlace::Clone),
|
Symbol::LIST_SET => list_set(parent, args, env, InPlace::Clone),
|
||||||
Symbol::LIST_SET_IN_PLACE => list_set(parent, args, env, InPlace::InPlace),
|
Symbol::LIST_SET_IN_PLACE => list_set(parent, args, env, InPlace::InPlace),
|
||||||
Symbol::LIST_PUSH => list_push(parent, args, env, InPlace::Clone),
|
Symbol::LIST_PUSH => list_push(parent, args, env),
|
||||||
Symbol::LIST_SINGLE => {
|
Symbol::LIST_SINGLE => {
|
||||||
// List.single : a -> List a
|
// List.single : a -> List a
|
||||||
debug_assert!(args.len() == 1);
|
debug_assert!(args.len() == 1);
|
||||||
|
@ -1653,7 +1653,6 @@ fn list_push<'a, 'ctx, 'env>(
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
args: &[(BasicValueEnum<'ctx>, &'a Layout<'a>)],
|
args: &[(BasicValueEnum<'ctx>, &'a Layout<'a>)],
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env>,
|
||||||
in_place: InPlace,
|
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
// List.push List elem, elem -> List elem
|
// List.push List elem, elem -> List elem
|
||||||
let builder = env.builder;
|
let builder = env.builder;
|
||||||
|
@ -1661,7 +1660,7 @@ fn list_push<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
debug_assert!(args.len() == 2);
|
debug_assert!(args.len() == 2);
|
||||||
|
|
||||||
let original_wrapper = args[1].0.into_struct_value();
|
let original_wrapper = args[0].0.into_struct_value();
|
||||||
|
|
||||||
// Load the usize length from the wrapper. We need it for bounds checking.
|
// Load the usize length from the wrapper. We need it for bounds checking.
|
||||||
let list_len = load_list_len(builder, original_wrapper);
|
let list_len = load_list_len(builder, original_wrapper);
|
||||||
|
@ -1673,7 +1672,7 @@ fn list_push<'a, 'ctx, 'env>(
|
||||||
let elems_ptr = load_list_ptr(builder, original_wrapper, ptr_type);
|
let elems_ptr = load_list_ptr(builder, original_wrapper, ptr_type);
|
||||||
|
|
||||||
let new_list_len = env.builder.build_int_add(
|
let new_list_len = env.builder.build_int_add(
|
||||||
ctx.i32_type().const_int(
|
ctx.i64_type().const_int(
|
||||||
// 0 as in 0 index of our new list
|
// 0 as in 0 index of our new list
|
||||||
1 as u64, false,
|
1 as u64, false,
|
||||||
),
|
),
|
||||||
|
@ -1729,7 +1728,7 @@ fn list_push<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
// Store the length
|
// Store the length
|
||||||
struct_val = builder
|
struct_val = builder
|
||||||
.build_insert_value(struct_val, list_len, Builtin::WRAPPER_LEN, "insert_len")
|
.build_insert_value(struct_val, new_list_len, Builtin::WRAPPER_LEN, "insert_len")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let answer = builder.build_bitcast(
|
let answer = builder.build_bitcast(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue