bytecodealliance / bytecodealliance/wasm-tools
Unstable error variant in unstable function leads to compilation error
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
The following WIT world fails to compile with `wit-bindgen==0.42.1` and the `tool` feature not being active. This error comes after introducing the `tool-error` variant and changing the return type of `invoke-tool` to a result:
```sh
error: found a reference to a type which is excluded due to its feature not being activated
--> .../wit-unstable/skill.wit:27:39
|
27 | invoke-tool: func(request: u8) -> result, error>;
| ^-----
--> src/main.rs:3:1
|
3 | generate!({ path: "skill.wit", world: "skill" });
```
It appears like a bug, as only small changes to the WIT world (changing the unrelated type of `output-schema` from a `list` to a `u8`) will lead to a successful compilation. My expectation would have been that it is possible to have unstable types in the signature of unstable functions.
```
package pharia:skill@0.3.0;
world skill {
import tool;
export skill-handler;
}
@since(version = 0.3.0)
interface skill-handler {
@since(version = 0.3.0)
record skill-metadata {
output-schema: list,
}
@since(version = 0.3.0)
metadata: func() -> skill-metadata;
}
interface tool {
@unstable(feature = tool)
variant error {
other(string)
}
@unstable(feature = tool)
invoke-tool: func(request: u8) -> result, error>;
}
```
A minimum reproducable example can be achieved with the following main:
```rust
use wit_bindgen::generate;
generate!({ path: "skill.wit", world: "skill" });
fn main() {
println!("Hello, world!");
}
```
Contributor guide
Assessment
This issue has not been assessed yet.