Skip to content

Conversation

@alexcrichton
Copy link
Member

This commit adds a new method to Resolve which is intended to resolve a longstanding issue for bindings generators based on wit-parser: #1497. Specifically this adds functionality to Resolve to duplicate exported interfaces and their contents, if necessary. This is a boon to bindings generators because it means that a TypeId, for example, uniquely identifies a single generated type. Previously it might refer to one of two types, either the imported version or the exported version. After this method, however, there will be two TypeIds if necessary.

This is currently modeled as a mutation to Resolve which is opt-in. This is done to avoid tampering with the AST-like structure of Resolve today where other AST-like operations don't want to necessarily have to keep everything in sync. Once a Resolve is nominalized, however, it's effectively incompatible with other operations such as merging, printing, etc. My thinking is that for now this is a reasonable tradeoff as bindings generators can pretty easily invoke this method before actually running bindings generation.

Closes #1497

This commit adds a new method to `Resolve` which is intended to resolve
a longstanding issue for bindings generators based on `wit-parser`: bytecodealliance#1497.
Specifically this adds functionality to `Resolve` to duplicate exported
interfaces and their contents, if necessary. This is a boon to bindings
generators because it means that a `TypeId`, for example, uniquely
identifies a single generated type. Previously it might refer to one of
two types, either the imported version or the exported version. After
this method, however, there will be two `TypeId`s if necessary.

This is currently modeled as a mutation to `Resolve` which is opt-in.
This is done to avoid tampering with the AST-like structure of `Resolve`
today where other AST-like operations don't want to necessarily have to
keep everything in sync. Once a `Resolve` is nominalized, however, it's
effectively incompatible with other operations such as merging,
printing, etc. My thinking is that for now this is a reasonable tradeoff
as bindings generators can pretty easily invoke this method before
actually running bindings generation.

Closes bytecodealliance#1497
@alexcrichton alexcrichton requested a review from a team as a code owner February 10, 2026 00:29
@alexcrichton alexcrichton requested review from dicej and pchickey and removed request for a team and pchickey February 10, 2026 00:29
# add version detection to build scripts but in other cases this may not be
# reasonable to expect.
rust-version = "1.81.0"
rust-version = "1.82.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for indexmap 2.13's replace_index 👍

@ricochet
Copy link
Contributor

This LGTM. I like how it's opt-in and won't impact existing workflows

@alexcrichton alexcrichton added this pull request to the merge queue Feb 10, 2026
Merged via the queue into bytecodealliance:main with commit 9501a05 Feb 10, 2026
36 checks passed
@alexcrichton alexcrichton deleted the nominal-type-ids branch February 10, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: wit-parser: create distinct imported and exported TypeDefs, Functions, and Interfaces in a Resolve

3 participants