Skip to content

Unstable error variant in unstable function leads to compilation error #2210

Open
@moldhouse

Description

@moldhouse

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:

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<list<u8>, 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<u8> 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<u8>,
    }

    @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<list<u8>, error>;
}

A minimum reproducable example can be achieved with the following main:

use wit_bindgen::generate;

generate!({ path: "skill.wit", world: "skill" });

fn main() {
    println!("Hello, world!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    witrelated to the `*.wit` text format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions