You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When option<a_number> is a function parameter type then Func::call often panics or the function body is not called at all. It doesn't matter whether the parameter is option or the parameter is a record containing the option.
I've made a runnable example in my fork, see the component's lib.rs:
impl exports::test::guest::foo::GuestforFoo{fnfn_calling_host_fn(){// 1)// Works as expected - prints `A message from host.`// WIT: `host-fn: func(param: option<s32>);`// Params: `[ValueType::Option(OptionType::new(ValueType::S32))]`
test::guest::host::host_fn(None);// 2)// Panics with the error `Invalid discriminant value.`// WIT: `host-fn: func(param: option<s32>);`// Params: `[ValueType::Option(OptionType::new(ValueType::S32))]`// test::guest::host::host_fn(Some(123));// 3)// Panics with the error `Incorrect type. src\func.rs:816:27` (see updated `require_matches` below)// WIT: `host-fn: func(param: option<f64>);`// Params: `[ValueType::Option(OptionType::new(ValueType::F64))]`// test::guest::host::host_fn(None);}}
Also it may behave differently on each runtime. For example, in my project, a function like host-fn: func(param: option<f64>) -> result; returns immediately Ok without running the Func body at all on the js_wasm_runtime_layer runtime and it works correctly when I change param: option<f64> to option<string> or option<s32>.
I've tried to upgrade wit-bindgen = "0.16.0" to "0.26.0" but it doesn't affect the issue.
Context: I was writing an example with wasm_component_layer in MoonZoon and then I would like to use it in another OS project with Tauri where I want to use both js_wasm_runtime_layer and wasmtime_runtime_layer. These bugs and missing bindgen are stoppers for me, unfortunately.
Hope it helps, ask me any questions.
The text was updated successfully, but these errors were encountered:
I don't know if this PR(#19) has anything to do with your problem.
If you have time, you can run the example and have a look. (README.md example part, run value_none example)
Feel free to contact me if you have any further questions, I am trying to implement WASIp2 with this repo.
Hi, I've probably found a bug.
When
option<a_number>
is a function parameter type thenFunc::call
often panics or the function body is not called at all. It doesn't matter whether the parameter isoption
or the parameter is arecord
containing theoption
.I've made a runnable example in my fork, see the component's lib.rs:
Also it may behave differently on each runtime. For example, in my project, a function like
host-fn: func(param: option<f64>) -> result;
returns immediatelyOk
without running theFunc
body at all on thejs_wasm_runtime_layer
runtime and it works correctly when I changeparam: option<f64>
tooption<string>
oroption<s32>
.I've tried to upgrade
wit-bindgen = "0.16.0"
to"0.26.0"
but it doesn't affect the issue.Context: I was writing an example with
wasm_component_layer
in MoonZoon and then I would like to use it in another OS project with Tauri where I want to use bothjs_wasm_runtime_layer
andwasmtime_runtime_layer
. These bugs and missing bindgen are stoppers for me, unfortunately.Hope it helps, ask me any questions.
The text was updated successfully, but these errors were encountered: