wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

Package namespaces and package names are not generatable in combination

Open cleanerx opened this issue 9 months ago • 5 comments

Looking at the wit-syntax the following is supported

package-decl ::= 'package' ( id ':' )+ id ( '/' id )* ('@' valid-semver)? ';'

Using it

package com:mydomain/tree/leaf;

interface foo {

record stat {
  ino: u64,
  size: u64,
}

}

world x { export foo; }

Generating fails with tool@6fddbba60b7a:/workspaces/test_wit# wit-bindgen rust my_interface.wit Error: expected '{', found / --> my_interface.wit:1:21 | 1 | package com:mydomain/tree/leaf; | ^

I think this should be supported

cleanerx avatar Mar 19 '25 10:03 cleanerx

Thanks for the report! I'll note that the structure of com:mydomain/tree/leaf is "emoji gated" in the component model at this time meaning it's not fully stable and implemented everywhere. What you're running into is that this is an example of it not being implemented.

alexcrichton avatar Mar 19 '25 14:03 alexcrichton

Does wit-bindgen have appetite for a PR for this? Or would you rather wait for the emoji to go away

ouillie avatar Jul 30 '25 06:07 ouillie

I think this'd be reasonable to support yeah, but I'd also caution you in that there's probably work to be done in the wasm-tools repository to fully support this feature of the component model. In that sense while I'm not exactly sure what the extent of work necessary is I'd predict that this wouldn't be a small PR to support this. (but happy to be proven wrong!)

alexcrichton avatar Jul 30 '25 15:07 alexcrichton

Actually I don't understand the purpose of ( '/' id )* in the production for package-decl. I thought the ID(s) after the slash were for sub-package objects like a world or an interface. So, why is it part of the package declaration?

ouillie avatar Jul 31 '25 01:07 ouillie

That might be dated, and/or not fully thought out. The design of extended package names was never fully fleshed out and/or rationalized with WIT. There's a lot of open questions I suspect, like the one you're running into.

alexcrichton avatar Jul 31 '25 14:07 alexcrichton