Open
Description
Give the following wit, the add
and call-host-with-return
function works but the add-no-return
and call-host
do not
package wasi-sample:example;
world example {
import host;
export adder;
}
interface adder {
add: func(left: u32, right: u32) -> u32;
add-no-return: func(left: u32, right: u32);
call-host: func(input: string);
call-host-with-return: func(input: string) -> string;
}
The error is:
thread 'main' panicked at src/hyperlight_wasm/examples/wasi_examples/main.rs:6:5:
bad return from guest Err(GuestError(GuestError, "Error: failed to convert function to given type\n\nCaused by:\n 0: type mismatch with results\n 1: expected 1-tuple, found 0-tuple"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The expanded WIT has a function registered with a return type, notice the return type registration
WIT_WORLD=$PWD/src/wasi_samples/wit/component-world.wasm HYPERLIGHT_COMPONENT_MACRO_DEBUG=/tmp/guest.rs cargo build -p hyperlight-wasm
::hyperlight_guest_bin::guest_function::register::register_function(
::hyperlight_guest_bin::guest_function::definition::GuestFunctionDefinition::new(
"r#wasi_sample::r#example::add-no-return".to_string(),
::alloc::vec![
::hyperlight_common::flatbuffer_wrappers::function_types::ParameterType::VecBytes,
::hyperlight_common::flatbuffer_wrappers::function_types::ParameterType::VecBytes
],
::hyperlight_common::flatbuffer_wrappers::function_types::ReturnType::VecBytes,
r#add_no_return as usize,
),
);