fix zig argument passing changes in str module

This commit is contained in:
Folkert 2022-04-06 15:38:47 +02:00
parent a69bf971f0
commit 5e0b724854
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 23 additions and 7 deletions

View file

@ -5337,7 +5337,17 @@ fn run_low_level<'a, 'ctx, 'env>(
let string = load_symbol(scope, &args[0]);
call_bitcode_fn(env, &[string], intrinsic)
let result = call_bitcode_fn(env, &[string], intrinsic);
// zig passes the result as a packed integer sometimes, instead of a struct. So we cast
let expected_type = basic_type_from_layout(env, layout);
let actual_type = result.get_type();
if expected_type != actual_type {
complex_bitcast_check_size(env, result, expected_type, "str_to_num_cast")
} else {
result
}
}
StrFromInt => {
// Str.fromInt : Int -> Str