Deal with fastcc return-by-pointer convention correctly

Closes #2582
This commit is contained in:
Ayaz Hafiz 2022-04-04 16:31:08 -04:00
parent 19c02aa087
commit 0f0e56a21c
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 12 additions and 1 deletions

View file

@ -3900,8 +3900,10 @@ fn make_exception_catching_wrapper<'a, 'ctx, 'env>(
let argument_types = match RocReturn::from_layout(env, &return_layout) {
RocReturn::Return => roc_function_type.get_param_types(),
RocReturn::ByPointer => {
// Our fastcc passes the return pointer as the last parameter.
// Remove the return pointer since we now intend to return the result by value.
let mut types = roc_function_type.get_param_types();
types.remove(0);
types.pop();
types
}