Bug report
I am trying to describe js builtins cast function in rust, the function is defined:
func cast(
string: externref
) -> (ref extern) {
// Technically a partially redundant test, but want to be clear the null is
// not allowed.
if (string === null ||
typeof string !== "string")
trap();
return string;
}
The function takes externref as input, which can be done with this crane. But the return value is "ref extern", it is an externref that is non nullable. Currently this crane preprocessor cant create a code that has correct return signature for this function, "ref extern" types are not supported. So this code will have error in the runtime when compiling the wasm
#[externref::externref]
#[link(wasm_import_module = "wasm:js-string")]
unsafe extern "C" {
fn cast(string: &Resource<()>) -> Resource<()>;
}
To support this, all Resource types should carry information if they are nullable, or preprocessor should create wasm code with logic something like this
Option<Resource> -> externref
Resource -> ref extern
Bug report
I am trying to describe js builtins cast function in rust, the function is defined:
The function takes externref as input, which can be done with this crane. But the return value is "ref extern", it is an externref that is non nullable. Currently this crane preprocessor cant create a code that has correct return signature for this function, "ref extern" types are not supported. So this code will have error in the runtime when compiling the wasm
To support this, all Resource types should carry information if they are nullable, or preprocessor should create wasm code with logic something like this