Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does converting to I32 with a uint32 value panic if the I32 type is sign agnostic? #382

Open
jimjbrettj opened this issue Apr 10, 2023 · 0 comments
Labels
❓ question Further information is requested

Comments

@jimjbrettj
Copy link

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

func fromGoValue(value interface{}, kind ValueKind) (C.wasm_val_t, error) {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant