Skip to content

Commit 8c0e56f

Browse files
committed
address comments
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
1 parent 5924d8e commit 8c0e56f

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

design/mvp/WIT.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ world my-world-1 {
312312
313313
// my-world-2.wit
314314
world my-world-2 {
315-
import a2: pkg.a
316-
import b2: pkg.b
317-
export c2: pkg.c
315+
import a1: pkg.a
316+
import b1: pkg.b
317+
export c1: pkg.c
318318
}
319319
320320
// union.wit
@@ -330,7 +330,29 @@ world union-my-world-4 {
330330
}
331331
```
332332

333-
As you can see, the names of the imports and exports in "union-my-world-4" are picking up the names from the first included world. This is because the second included world has structurally the same imports and exports and are deduplicated.
333+
Notice that if the two included worlds have different names for the same import or export, then it will be considered as an error, even if the interfaces are strcuturally the same. For example, the following worlds `my-world-1` and `my-world-2` are not structurally equivalent, but the `include` statement will report an error:
334+
335+
```wit
336+
// my-world-1.wit
337+
world my-world-1 {
338+
import a1: pkg.a
339+
import b1: pkg.b
340+
export c1: pkg.c
341+
}
342+
343+
// my-world-2.wit
344+
world my-world-2 {
345+
import a2: pkg.a
346+
import b2: pkg.b
347+
export c2: pkg.c
348+
}
349+
350+
// union.wit
351+
world union-my-world-3 {
352+
include pkg.my-world-1
353+
include pkg.my-world-2
354+
}
355+
```
334356

335357
### De-duplication with `with`
336358

@@ -369,10 +391,10 @@ world union-my-world-6 {
369391

370392
### A Note on SubTyping
371393

372-
As of now, host bindings are required to implicitly interpret all exports as optional to make a component targeting an included World a subtype of the union World. This [comment](https://github.com/WebAssembly/component-model/issues/169#issuecomment-1446776193) describes the reasoning behind this decision.
373-
374394
In the future, when `optional` export is supported, the world author may explicitly mark exports as optional to make a component targeting an included World a subtype of the union World.
375395

396+
For now, we are not following the subtyping rules for the `include` statement. That is, the `include` statement does not imply any subtyping relationship between the included worlds and the union world.
397+
376398
## WIT Packages and `use`
377399
[use]: #wit-packages-and-use
378400

0 commit comments

Comments
 (0)