Skip to content

Commit febfe39

Browse files
abrownlukewagner
authored andcommitted
review: re-work the EBNF and note based on PR discussion
1 parent 6f98299 commit febfe39

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

design/mvp/Binary.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ Notes:
137137
(See [Type Definitions](Explainer.md#type-definitions) in the explainer.)
138138
```ebnf
139139
core:type ::= dt:<core:deftype> => (type dt) (GC proposal)
140-
core:deftype ::= ft:<core:functype> => ft (WebAssembly 1.0)
141-
| 0x00 rt:<core:rectype> => rt (WebAssembly 3.0)
140+
core:deftype ::= rt:<core:rectype> => rt (WebAssembly 3.0)
142141
| mt:<core:moduletype> => mt
143142
core:moduletype ::= 0x50 md*:vec(<core:moduledecl>) => (module md*)
144143
core:moduledecl ::= 0x00 i:<core:import> => i
@@ -152,14 +151,14 @@ core:exportdecl ::= n:<core:name> d:<core:importdesc> => (export n d)
152151
```
153152
Notes:
154153
* Reused Core binary rules: [`core:import`], [`core:importdesc`],
155-
[`core:functype`], [`core:rectype`]
156-
* The three branches of `core:deftype` have prefix bytes of 0x60
157-
(`core:functype`), 0x50 (`core:moduletype` ), and 0x00 (`core:rectype`). This
158-
is because the component model and the GC specifications (i.e., source of
159-
`core:rectype`) have evolved in parallel and independently. Ideally, in the
160-
future, the `core:functype` production would be removed as it can be expressed
161-
within `core:rectype`. Also, the prefix byte of `core:moduletype` (0x50) will
162-
also likely change as well.
154+
[`core:rectype`]
155+
* Unfortunately, the `core:deftype` rule results in an encoding ambiguity: the
156+
`0x50` opcode is used by both `core:moduletype` and `core:subtype`, which can
157+
be decoded as a top-level form of `core:rectype`. To resolve this, prior to
158+
v1.0 of this specification, we require `core:subtype` to be prefixed by `0x00`
159+
in this context (i.e., a `sub` as a component core type is `0x00 0x50`;
160+
elsewhere, `0x50`). By the v1.0 release of this specification,
161+
`core:moduletype` will receive a new, non-overlapping opcode.
163162
* Validation of `core:moduledecl` rejects `core:moduletype` definitions
164163
and `outer` aliases of `core:moduletype` definitions inside `type`
165164
declarators. Thus, as an invariant, when validating a `core:moduletype`, the

0 commit comments

Comments
 (0)