Skip to content

Commit f065ad3

Browse files
authored
Merge pull request #73 from WebAssembly/fix-core-outer-alias
Add 'outer' case to <core:alias> to match Binary.md
2 parents 5f1ee60 + 23d6e1e commit f065ad3

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

design/mvp/Binary.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ Notes:
117117
index in the `sort` index space of the `i`th enclosing component (counting
118118
outward, starting with `0` referring to the current component).
119119
* For `outer` aliases of `core:aliastarget`, validation restricts the `sort` to
120-
`type`.
120+
`type` and `ct` must be `0` (for a component-level definition; see also the
121+
`core:alias` case of `core:moduledecl` below).
121122
* For `outer` aliases of `aliastarget`, validation restricts the `sort` to one
122123
of `type`, `module` or `component`.
123124

design/mvp/Explainer.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ component):
227227
```
228228
core:alias ::= (alias <core:aliastarget> (<core:sort> <id>?))
229229
core:aliastarget ::= export <core:instanceidx> <name>
230+
| outer <u32> <u32>
230231
231232
alias ::= (alias <aliastarget> (<sort> <id>?))
232233
aliastarget ::= export <instanceidx> <name>
@@ -242,17 +243,19 @@ In the case of `export` aliases, validation ensures `name` is an export in the
242243
target instance and has a matching sort.
243244

244245
In the case of `outer` aliases, the `u32` pair serves as a [de Bruijn
245-
index], with first `u32` being the number of enclosing components to skip
246-
and the second `u32` being an index into the target component's sort's index
247-
space. In particular, the first `u32` can be `0`, in which case the outer
248-
alias refers to the current component. To maintain the acyclicity of module
249-
instantiation, outer aliases are only allowed to refer to *preceding* outer
250-
definitions.
251-
252-
There is no `outer` option in `core:aliastarget` because it would only be able
253-
to refer to enclosing *core* modules and module types and, until
254-
module-linking, modules and module types can't nest. In a module-linking
255-
future, outer aliases would be added, making `core:alias` symmetric to `alias`.
246+
index], with first `u32` being the number of enclosing components/modules to
247+
skip and the second `u32` being an index into the target's sort's index space.
248+
In particular, the first `u32` can be `0`, in which case the outer alias refers
249+
to the current component. To maintain the acyclicity of module instantiation,
250+
outer aliases are only allowed to refer to *preceding* outer definitions.
251+
252+
As with other core definitions, core aliases are only supposed to "see" other
253+
core definitions (as-if they were defined by Core WebAssembly extended with
254+
[module-linking]). Thus, core `outer` aliases must have a skip-count of `0`
255+
when defined within a component, only allowing them to duplicate core
256+
definitions in core index spaces. (Core `outer` aliases have a second use
257+
described in the next section, which is why they are included in the grammar
258+
at all.)
256259

257260
Components containing outer aliases effectively produce a [closure] at
258261
instantiation time, including a copy of the outer-aliased definitions. Because

0 commit comments

Comments
 (0)