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:
Chelsea Troy 2021-10-25 00:06:37 -05:00
parent 9633a5adaa
commit 063d7b178b
No known key found for this signature in database
GPG key ID: A631885A970636C2
2 changed files with 19 additions and 11 deletions

View file

@ -2043,7 +2043,7 @@ fn list_drop_last(symbol: Symbol, var_store: &mut VarStore) -> Def {
defn(
symbol,
vec![(list_var, Symbol::ARG_1), (index_var, Symbol::ARG_2)],
vec![(list_var, Symbol::ARG_1)],
var_store,
body,
list_var,

View file

@ -344,20 +344,28 @@ pub fn list_drop_at<'a, 'ctx, 'env>(
/// List.dropLast : List elem -> List elem
pub fn list_drop_last<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout_ids: &mut LayoutIds<'a>,
original_wrapper: StructValue<'ctx>,
count: IntValue<'ctx>,
element_layout: &Layout<'a>,
list: BasicValueEnum<'ctx>,
list_layout: &Layout<'a>,
update_mode: UpdateMode,
) -> 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(
env,
&[
pass_list_cc(env, original_wrapper.into()),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
count.into(),
dec_element_fn.as_global_value().as_pointer_value().into(),
pass_list_cc(env, list),
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
pass_update_mode(env, update_mode),
],
bitcode::LIST_DROP_LAST,
)