Skip to content

Add implements clause support to wac#200

Merged
fibonacci1729 merged 1 commit into
bytecodealliance:mainfrom
ricochet:implements
Jul 13, 2026
Merged

Add implements clause support to wac#200
fibonacci1729 merged 1 commit into
bytecodealliance:mainfrom
ricochet:implements

Conversation

@ricochet

@ricochet ricochet commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Adds support for composing components that use the component model (implements "I") clause (component-model#613), which lets a component import or export the same interface more than once under different plain-names.

  world consumer {
    import primary: wasi:keyvalue/store;
    import backup:  wasi:keyvalue/store;
  }

In the binary this encodes each extern with a plain-name label and an (implements "…") directive carrying the interface it implements:

(component
  (import "primary" (implements "wasi:keyvalue/store") (instance ...))
  (import "secondary" (implements "wasi:keyvalue/store") (instance ...))
)

This change makes it so that each labeled extern is preserved as its own instance and round-trips the implements directive.

Bump to latest wasm-tools which has implements support. Part of this was also adding ComponentItem to TypeConverter::entity, and for an instance extern, resolves the interface id from the implements metadata when present.

@ricochet ricochet force-pushed the implements branch 2 times, most recently from f2893ca to e0a96b3 Compare June 16, 2026 21:18
Support the component model's implements name form, which allows
importing/exporting the same interface multiple times under different
plain-name labels (e.g., primary/backup stores).
@ricochet ricochet marked this pull request as ready for review June 18, 2026 14:04
@ricochet ricochet requested a review from fibonacci1729 June 25, 2026 18:17
@fibonacci1729

fibonacci1729 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@ricochet thanks for driving this! Ack'ing your review request -- i'll start digging into this over the next few days / week.

@fibonacci1729 fibonacci1729 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great!

I think it would be great to add a test that explicitly exercises the spec's more subtle transitive use case where two labeled imports of an interface should share a separately imported types interface resource instead of duplicating it. I don't believe the code mishandles that case, but it is the main scenario I'd like to see covered because the spec discussion calls it out as important.

@fibonacci1729 fibonacci1729 merged commit 43db163 into bytecodealliance:main Jul 13, 2026
7 checks passed
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.

2 participants