Skip to content

Commit 2742292

Browse files
committed
Tweak type ascription validation rules to check subtyping, not type equality
1 parent e9f4ab3 commit 2742292

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

design/mvp/Binary.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,8 @@ Notes:
339339
validation errors (which coincides with definition of `URL` in JS and `rust-url`).
340340
* Validation requires any exported `sortidx` to have a valid `externdesc`
341341
(which disallows core sorts other than `core module`). When the optional
342-
`externdesc` immediate is present, validation requires it to be equal to
343-
the inferred `externdesc` of the `sortidx` (where equality judges a type and
344-
the `typeidx` of an export of that type (via `eq` or `sub`) equivalent).
342+
`externdesc` immediate is present, validation requires it to be a supertype
343+
of the inferred `externdesc` of the `sortidx`.
345344
* The `name` fields of `externname` must be unique among imports and exports,
346345
respectively. The `URL` fields of `externname` (that are present) must
347346
independently unique among imports and exports, respectively.

design/mvp/Explainer.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,9 +1313,10 @@ exported).
13131313
Validation of `export` requires that all transitive uses of resource types in
13141314
the types of exported functions or values refer to resources that were either
13151315
imported or exported (concretely, via the type index introduced by an `import`
1316-
or `export`). The optional `<externdesc>?` in `export` can be used to ascribe
1317-
an equivalent-but-different type to an exported definition, allowing a private
1318-
type definition to be replaced with a public (exported) type definition.
1316+
or `export`). The optional `<externdesc>?` in `export` can be used to
1317+
explicitly ascribe a type to an export which is validated to be a supertype of
1318+
the definition's type, thereby allowing a private (non-exported) type
1319+
definition to be replaced with a public (exported) type definition.
13191320

13201321
For example, in the following component:
13211322
```wasm

0 commit comments

Comments
 (0)