mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
fix 32-bit wasm to num conversion
This commit is contained in:
parent
af4023f116
commit
acf22ebf7e
2 changed files with 17 additions and 19 deletions
|
@ -227,14 +227,23 @@ pub(crate) fn run_low_level<'a, 'ctx, 'env>(
|
|||
intrinsic,
|
||||
),
|
||||
None => {
|
||||
let return_type = zig_function_type.get_param_types()[0]
|
||||
.into_pointer_type()
|
||||
.get_element_type()
|
||||
.into_struct_type()
|
||||
.into();
|
||||
let return_type_name = match number_layout {
|
||||
Layout::Builtin(Builtin::Int(int_width)) => int_width.type_name(),
|
||||
Layout::Builtin(Builtin::Decimal) => {
|
||||
// zig picks 128 for dec.RocDec
|
||||
"i128"
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let zig_return_alloca =
|
||||
create_entry_block_alloca(env, parent, return_type, "str_to_num");
|
||||
let return_type = zig_num_parse_result_type(env, return_type_name);
|
||||
|
||||
let zig_return_alloca = create_entry_block_alloca(
|
||||
env,
|
||||
parent,
|
||||
return_type.into(),
|
||||
"str_to_num",
|
||||
);
|
||||
|
||||
let (a, b) =
|
||||
pass_list_or_string_to_zig_32bit(env, string.into_struct_value());
|
||||
|
|
|
@ -1362,18 +1362,7 @@ fn str_trim_right_small_to_small_shared() {
|
|||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_to_nat() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toNat "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
),
|
||||
1,
|
||||
usize
|
||||
);
|
||||
assert_evals_to!(r#"Str.toNat "1" |> Result.withDefault 0"#, 1, usize);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue