argument_type_from_layout takes layoutrepr

This commit is contained in:
Ayaz Hafiz 2023-06-16 22:03:34 -05:00
parent ee25735731
commit 7ab044d79f
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 45 additions and 29 deletions

View file

@ -316,7 +316,8 @@ pub(crate) fn run_low_level<'a, 'ctx>(
// zig passes the result as a packed integer sometimes, instead of a struct. So we cast if needed.
// We check the type as expected in an argument position, since that is how we actually will use it.
let expected_type = argument_type_from_layout(env, layout_interner, layout);
let expected_type =
argument_type_from_layout(env, layout_interner, layout_interner.get_repr(layout));
let actual_type = result.get_type();
if expected_type != actual_type {
@ -2148,8 +2149,11 @@ fn build_int_unary_op<'a, 'ctx, 'env>(
)
.into_struct_type();
// How the return type is actually used, in the Roc calling convention.
let return_type_use_type =
convert::argument_type_from_layout(env, layout_interner, return_layout);
let return_type_use_type = convert::argument_type_from_layout(
env,
layout_interner,
layout_interner.get_repr(return_layout),
);
if arg_always_fits_in_target {
// This is guaranteed to succeed so we can just make it an int cast and let LLVM