From b6beda96d5b5f7a2a5425ce30b16ed6a1c970e6f Mon Sep 17 00:00:00 2001 From: Bailey Hayes Date: Wed, 25 Feb 2026 10:05:12 -0500 Subject: [PATCH 1/2] Add [implements=]L for multiple imports Extend the WIT `extern-type` grammar to allow `use-path` as a third case, enabling `import id: use-path` and `export id: use-path` to create plain-named imports/exports whose instance type matches a named interface. This allows importing the same interface multiple times under different plain names (e.g., `import primary: store; import secondary: store;`), encoded using the `[implements=]label` annotation pattern. Fixes #287 Co-authored-by: Luke Wagner --- design/mvp/Binary.md | 14 +++-- design/mvp/Explainer.md | 32 +++++++++-- design/mvp/WIT.md | 94 ++++++++++++++++++++++++++++++++- test/wasm-tools/implements.wast | 78 +++++++++++++++++++++++++++ test/wasm-tools/naming.wast | 31 +++++++++++ 5 files changed, 240 insertions(+), 9 deletions(-) create mode 100644 test/wasm-tools/implements.wast diff --git a/design/mvp/Binary.md b/design/mvp/Binary.md index 3a2fa83b..c5979ab0 100644 --- a/design/mvp/Binary.md +++ b/design/mvp/Binary.md @@ -408,11 +408,15 @@ Notes: [text format](Explainer.md#import-and-export-definitions). * The ``s of a component must all be [strongly-unique]. Separately, the ``s of a component must also all be [strongly-unique]. -* Validation requires that annotated `plainname`s only occur on `func` imports - or exports and that the first label of a `[constructor]`, `[method]` or - `[static]` matches the `plainname` of a preceding `resource` import or - export, respectively, in the same scope (component, component type or - instance type). +* Validation requires that `[constructor]`, `[method]` and `[static]` annotated + `plainname`s only occur on `func` imports or exports and that the first label + of a `[constructor]`, `[method]` or `[static]` matches the `plainname` of a + preceding `resource` import or export, respectively, in the same scope + (component, component type or instance type). +* Validation requires that `[implements=]` annotated `plainname`s only + occur on `instance` imports or exports. +* Validation requires that `interfacename`-named imports or exports are + `instance`-typed. * Validation of `[constructor]` names requires a `func` type whose result type is either `(own $R)` or `(result (own $R) E?)` where `$R` is a resource type labeled `r`. diff --git a/design/mvp/Explainer.md b/design/mvp/Explainer.md index ebf37a57..00ac2ac9 100644 --- a/design/mvp/Explainer.md +++ b/design/mvp/Explainer.md @@ -2538,6 +2538,7 @@ plainname ::=