Repository navigation
fix(wit-parser)!: preserve docs on world interface imports/exports - #2540
Conversation
alexcrichton
left a comment
There was a problem hiding this comment.
Looks like a re-bless may be needed, but otherwise looks good to me, thanks!
3b97a1e to
7fc7665
Compare
|
A possible wrinkle that I just remembered this morning as well -- deserialization here uses |
Doc comments attached to a world's by-reference interface `import`/`export` statements (e.g. the comments above `import wasi:cli/stdout;` and `export handler;` in wasi:http's `world service`) were silently dropped when a WIT package was encoded to its binary component form. Fix this by: * adding a `docs` field to `WorldItem::Interface` and threading the statement docs through the resolver and world elaboration, * extracting/injecting those docs via the `package-docs` section, mirroring the existing per-interface stability mechanism, * printing them for `WorldKey::Interface` items, preferring the statement docs and only falling back to the interface definition's docs for inline interfaces. Docs on `include` statements remain unsupported. Includes are flattened into imports/exports on encode, so they cannot survive the binary round-trip. Adds a `world-interface-docs` round-trip test and updates the `wasi-http` snapshots to include the previously-dropped docs. Signed-off-by: Bailey Hayes <[email protected]>
7fc7665 to
8840cd1
Compare
|
I ran through a couple manual sanity checks. Verified that we don't impact guest components (non-WIT-only) by embedding a world (with import/export statement docs) into a core module the way wit-bindgen does then decoded. That worked since guest components never carry package-docs, and they're decoded via encode_world/decode_world. I installed wasm-tools 1.251.0 and pointed it at a new-encoded wasi-http. This is the failure folks will see: error: unknown field `interface_import_docs`, expected one of `docs`, `stability`, `interfaces`, `types`, `funcs`, `interface_exports`, `func_exports`, `interface_import_stability`, `interface_export_stability` (exit 1) |
|
Thanks for double-checking! I don't think that's necessarily a discoverable/debuggable error, but I suspect that it'll be rare enough that it'll be fine 👍 |
wasm-tools 1.252.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed * Converge to unicode-ident and remove unicode-xid dependency by @Marcondiro in bytecodealliance/wasm-tools#2535 * wasm-smith: Allow limiting the size of const arrays by @alexcrichton in bytecodealliance/wasm-tools#2536 * fix(wit-encoder): only use serde attribute if serde is enabled by @MendyBerger in bytecodealliance/wasm-tools#2538 * Enable the `CM_ASYNC` feature by default by @alexcrichton in bytecodealliance/wasm-tools#2539 * fix(wit-parser)!: preserve docs on world interface imports/exports by @ricochet in bytecodealliance/wasm-tools#2540 * Release wasm-tools 1.252.0 by @github-actions[bot] in bytecodealliance/wasm-tools#2541 ## New Contributors * @Marcondiro made their first contribution in bytecodealliance/wasm-tools#2535 **Full Changelog**: https://github.com/bytecodealliance/wasm-tools/compare/v1.251.0...v1.252.0</pre> <p>View the full release notes at <a href="https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.252.0">https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.252.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11447
Doc comments attached to a world's by-reference interface
import/exportstatements (e.g. the comments aboveimport wasi:cli/stdout;andexport handler;inwasi:http'sworld service) were silently dropped when a WIT package was encoded to its binary component form.Fix this by:
docsfield toWorldItem::Interfaceand threading the statement docs through the resolver and world elaboration,package-docssection, mirroring the existing per-interface stability mechanism,WorldKey::Interfaceitems, preferring the statement docs and only falling back to the interface definition's docs for inline interfaces.Docs on
includestatements remain unsupported. Includes are flattened into imports/exports on encode, so they cannot survive the binary round-trip.Adds a
world-interface-docsround-trip test and updates thewasi-httpsnapshots to include the previously-dropped docs.Important
This is a breaking change. Backward compatibility with newer wasm-tools decoding old WIT-only components works, but forward compatibility will hard error (old wasm-tools reading new WIT-only component).