Stream: wasmtime

Topic: include support in `bindgen!`


view this post on Zulip alisomay (Jul 06 2023 at 15:12):

I'm trying to use wasmtime::component::bindgen! on a wit like this I get a parse error like output

expected `import`, `export`, `use`, or type definition, found an identifier
// ..

world union-my-world {
     include my-world-a
     include my-world-b
}

Is there a possibility that include statement is not supported yet?

My purpose here is to deduplicate the generated code between two worlds which shares dependencies.
Following the suggestion here: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#de-duplication-of-ids

Repository for design and specification of the Component Model - component-model/design/mvp/WIT.md at main · WebAssembly/component-model

view this post on Zulip alisomay (Jul 06 2023 at 15:30):

According to the wit-parser code base it is supported:

impl<'a> WorldItem<'a> {
    fn parse(tokens: &mut Tokenizer<'a>, docs: Docs<'a>) -> Result<WorldItem<'a>> {
        match tokens.clone().next()? {
            //.. many patterns
            Some((_span, Token::Include)) => Include::parse(tokens).map(WorldItem::Include),
            other => Err(err_expected(
                tokens,
                "`import`, `export`, `include`, `use`, or type definition",
                other,
            )
            .into()),
        }
    }
}

And here is my parse error.
On the other hand it says

"`import`, `export`, `include`, `use`, or type definition"

here.
So maybe wasmtime::component::bindgen! uses a different version of the parser. Let me check further..

view this post on Zulip Pat Hickey (Jul 10 2023 at 18:19):

There hasn't yet been a release of wit-parser that supports include

view this post on Zulip Pat Hickey (Jul 10 2023 at 18:19):

the PR landed on june 13, and a few bugfixes since then, but we havent cut a release. i expect we will once the resources work looks solid enough


Last updated: Nov 22 2024 at 16:03 UTC