Skip to content

Outer alias of 0 to impure definitions #2545

Description

@bvisness

The component model explainer has this to say about outer aliases, emphasis mine:

Because components, like modules, are pure values, outer aliases that reach across component boundaries are restricted to only refer to pure definitions: modules, components, and types that do not transitively refer to a resource type.

It also makes it clear, though, that 0 is a valid instance index for an outer alias:

In particular, the first u32 can be 0, in which case the outer alias refers to the current component/type.

These two together would seemingly imply that it is valid to do the following:

(component
  (core module $m (func (export "foo")))
  (alias core export $m "foo" (core func $foo))
  (alias outer 0 $foo (core func $fooAgain))
)

But wasm-tools rejects this:

error: unexpected token, expected `module` or `type`
     --> stoopid.wat:4:29
      |
    4 |   (alias outer 0 $foo (core func $fooAgain))
      |                             ^

It seems like wasm-tools has restricted all outer aliases to pure definitions, not just those that reach across component boundaries. Is this a bug in wasm-tools or the component spec?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions