Closed sunfishcode closed 2 months ago
It's a good general question of whether to try to have the ABI trap as much as possible or, rather, check only what's necessary. Initially, I had the rules try to trap as much as possible, but in a few cases, this ended up rather complicating things so, to avoid being inconsistent, we changed our default to only trap when necessary. Note that, while lifting allows the incoming value to be greater than 1
, lowering guarantees you a 0
or 1
, so I think you should have no-op conversions of list<bool>
in both directions.
And yeah, I suppose i32_to_char
should get a verb before it like all the other verb_x_to_y
functions. Fixed
The question has been answered!
The Canonical ABI says
Why does it work this way, instead of doing
trap_if(i >= 2)
similar to whati32_to_char
does?(Aside: the names
convert_int_to_bool
andi32_to_char
are a little inconsistent.)Rust and many popular C and C++ ABIs use a convention of 0 meaning false and 1 meaning true, and could perform a no-op conversion of things like
list<bool>
into the source language if the Canonical ABI would guarantee that representation as well.