mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
wasm: Fix Wasm type mismatch for empty closure data in List.mapN
This commit is contained in:
parent
bdad1a5161
commit
ae05e870af
1 changed files with 11 additions and 16 deletions
|
@ -1016,22 +1016,17 @@ pub fn call_higher_order_lowlevel<'a>(
|
||||||
|
|
||||||
let wrapper_fn_idx = backend.register_helper_proc(wrapper_sym, wrapper_layout, source);
|
let wrapper_fn_idx = backend.register_helper_proc(wrapper_sym, wrapper_layout, source);
|
||||||
let wrapper_fn_ptr = backend.get_fn_table_index(wrapper_fn_idx);
|
let wrapper_fn_ptr = backend.get_fn_table_index(wrapper_fn_idx);
|
||||||
let inc_fn_ptr = backend.get_refcount_fn_ptr(closure_data_layout, HelperOp::Inc);
|
let inc_fn_ptr = match closure_data_layout {
|
||||||
|
Layout::Struct {
|
||||||
match op {
|
field_layouts: &[], ..
|
||||||
// List.map : List elem_x, (elem_x -> elem_ret) -> List elem_ret
|
} => {
|
||||||
ListMap { xs } => {
|
// Our code gen would ignore the Unit arg, but the Zig builtin passes a pointer for it!
|
||||||
let list_x = backend.storage.symbol_layouts[xs];
|
// That results in an exception (type signature mismatch in indirect call).
|
||||||
|
// The workaround is to use I32 layout, treating the (ignored) pointer as an integer.
|
||||||
let (elem_x, elem_ret) = match (list_x, return_layout) {
|
backend.get_refcount_fn_ptr(Layout::Builtin(Builtin::Int(IntWidth::I32)), HelperOp::Inc)
|
||||||
(
|
}
|
||||||
Layout::Builtin(Builtin::List(elem_x)),
|
_ => backend.get_refcount_fn_ptr(closure_data_layout, HelperOp::Inc),
|
||||||
Layout::Builtin(Builtin::List(elem_ret)),
|
};
|
||||||
) => (elem_x, elem_ret),
|
|
||||||
_ => internal_error!("invalid arguments layout for {:?}", op),
|
|
||||||
};
|
|
||||||
let elem_x_size = elem_x.stack_size(TARGET_INFO);
|
|
||||||
let (elem_ret_size, elem_ret_align) = elem_ret.stack_size_and_alignment(TARGET_INFO);
|
|
||||||
|
|
||||||
match op {
|
match op {
|
||||||
ListMap { xs } => list_map_n(
|
ListMap { xs } => list_map_n(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue