mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Figured out why dropLast call was producing an argument mismatch:
- Although list_drop_last's LowLevel operation modeling (body) was correct, the defn() CALLED that body with an extra argument for index (a copy-paste error from dropAt). - List.dropAt works now :)
This commit is contained in:
parent
9633a5adaa
commit
063d7b178b
2 changed files with 19 additions and 11 deletions
|
@ -2043,7 +2043,7 @@ fn list_drop_last(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||||
|
|
||||||
defn(
|
defn(
|
||||||
symbol,
|
symbol,
|
||||||
vec![(list_var, Symbol::ARG_1), (index_var, Symbol::ARG_2)],
|
vec![(list_var, Symbol::ARG_1)],
|
||||||
var_store,
|
var_store,
|
||||||
body,
|
body,
|
||||||
list_var,
|
list_var,
|
||||||
|
|
|
@ -344,20 +344,28 @@ pub fn list_drop_at<'a, 'ctx, 'env>(
|
||||||
/// List.dropLast : List elem -> List elem
|
/// List.dropLast : List elem -> List elem
|
||||||
pub fn list_drop_last<'a, 'ctx, 'env>(
|
pub fn list_drop_last<'a, 'ctx, 'env>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env>,
|
||||||
layout_ids: &mut LayoutIds<'a>,
|
list: BasicValueEnum<'ctx>,
|
||||||
original_wrapper: StructValue<'ctx>,
|
list_layout: &Layout<'a>,
|
||||||
count: IntValue<'ctx>,
|
update_mode: UpdateMode,
|
||||||
element_layout: &Layout<'a>,
|
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout);
|
let element_layout = match *list_layout {
|
||||||
|
Layout::Builtin(Builtin::EmptyList) => {
|
||||||
|
// this pointer will never actually be dereferenced
|
||||||
|
Layout::Builtin(Builtin::Int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout::Builtin(Builtin::List(elem_layout)) => *elem_layout,
|
||||||
|
|
||||||
|
_ => unreachable!("Invalid layout {:?} in List.dropLast", list_layout),
|
||||||
|
};
|
||||||
|
|
||||||
call_bitcode_fn_returns_list(
|
call_bitcode_fn_returns_list(
|
||||||
env,
|
env,
|
||||||
&[
|
&[
|
||||||
pass_list_cc(env, original_wrapper.into()),
|
pass_list_cc(env, list),
|
||||||
env.alignment_intvalue(element_layout),
|
env.alignment_intvalue(&element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, &element_layout),
|
||||||
count.into(),
|
pass_update_mode(env, update_mode),
|
||||||
dec_element_fn.as_global_value().as_pointer_value().into(),
|
|
||||||
],
|
],
|
||||||
bitcode::LIST_DROP_LAST,
|
bitcode::LIST_DROP_LAST,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue