Why does converting to I32 with a uint32 value panic if the I32 type is sign agnostic?
jimjbrettj opened this issue · comments
JimboJ commented
Summary
It is my understanding that the I32 type is sign agnostic, meaning it should be able to handle both int32 and uint32 types. However this is not how wasmer appears to handle it. See this code snippet:
`case I32:
output.kind = kind.inner()
var of = (*int32)(unsafe.Pointer(&output.of))
switch value.(type) {
case int8:
*of = int32(value.(int8))
case uint8:
*of = int32(value.(uint8))
case int16:
*of = int32(value.(int16))
case uint16:
*of = int32(value.(uint16))
case int32:
*of = value.(int32)
case int:
*of = int32(value.(int))
case uint:
*of = int32(value.(uint))
default:
return output, newErrorWith("i32")
}`
from
Line 207 in ca60a45
I need to pass in uint32 values, and I had expected that they should be encompased in the I32 type, but my code panics. Am I misunderstanding something here or is this a bug?
Any help/guidance would be appreciated, thanks!
Additional details
Provide any additional details here.