I'm getting this error:
types incompatible: expected type `(func (param (ref array (engine 5))))`, found type `(func (param (ref array)))`
The wasm looks like this:
(type $String (;3;) (array i8))
(type $debug.type (;4;) (func (param (ref $String))))
(import "host" "debug" (func $debug (;0;) (type $debug.type)))
And I'm registering the function like this:
let engine = wasmtime::Engine::new(&config).unwrap();
let store = wasmtime::Store::<StoreData>::new(&engine, ());
let mut linker = wasmtime::Linker::new(&engine);
linker
.func_wrap(
"host",
"debug",
|caller: Caller<'_, StoreData>, param: Rooted<ArrayRef>| {
// ...
},
)
.unwrap();
Also: what's the best way to access the bytes of the array as a string?
I think that might be a bug because that looks like it's expected to work, mind filing an issue?
For getting the array as a string we need to add APIs to do that, they're not currently present on ArrayRef
so you'd have to access it byte-by-byte (which probably isn't the speediest)
hm so my guess is that it's (array mut i8)
vs (array i8)
, we might not have anything in the API to match that
but if you try changing the type to (array mut i8)
it may work for now?
(I could also be totally off)
Changing from types.ty().array(&StorageType::I8, false)
to types.ty().array(&StorageType::I8, true)
didn't seem to make any difference. Even the error message was the same.
Ah ok I'm just barking up the wrong tree then, we can properly investigate this in an issue
Bug filed: https://github.com/bytecodealliance/wasmtime/issues/9848
Thanks!
Last updated: Dec 23 2024 at 13:07 UTC