Support upcasting bools to ints in the wasm backend

This commit is contained in:
Ayaz Hafiz 2022-10-04 18:55:45 -05:00
parent 725054b8f3
commit c7bd4e1c1c
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -50,6 +50,7 @@ impl From<Layout<'_>> for CodeGenNumType {
|| internal_error!("Tried to perform a Num low-level operation on {:?}", layout);
match layout {
Layout::Builtin(builtin) => match builtin {
Builtin::Bool => I32,
Builtin::Int(int_width) => match int_width {
IntWidth::U8 => I32,
IntWidth::U16 => I32,
@ -1723,6 +1724,7 @@ impl<'a> LowLevelCall<'a> {
let arg_type = CodeGenNumType::from(arg_layout);
let arg_width = match arg_layout {
Layout::Builtin(Builtin::Int(w)) => w,
Layout::Builtin(Builtin::Bool) => IntWidth::U8,
x => internal_error!("Num.intCast is not defined for {:?}", x),
};