Skip to content

Validation text around outer aliases may be incomplete #771

Open

Description

@alexcrichton

I believe the intention is that outer aliases that cross a component boundary must be substitutable inline, so that nested components can be unbundled. In Binary.md it applies the resource check only to the type sort, but a component's type can also outer-alias a resource, so an outer alias of an imported component can't always be unbundled. I think this is valid via the currently documented rules (and accepted via wasm-tools):

(component $C
  (import "r" (type $r (sub resource)))
  (import "c" (component $c
    (alias outer $C $r (type $x))
    (export "x" (type (eq $x)))))
  (component $N
    (alias outer $C $c (component $c))
    (instance $i (instantiate $c))
    (alias export $i "x" (type $x))
    (export "x" (type $x))))

So I wanted to confirm, outer aliases of the component sort should get the same transitive resource check as type, right?

Or, alternatively, is this supposed to be invalid?

(component $C
  (import "r" (type $r (sub resource)))
  (import "c" (component $c
    (alias outer $C $r (type $x))
    (export "x" (type (eq $x))))))

(I forget the precise rules here myself)

Activity

  1. lukewagner commented on Nov 19, 2026

    @lukewagner
    Member

    Great question. I think your first and second examples shouldn't validate, and thus the first example fails validation before it even gets to the definition of $N. In particular, I think the rule we need is: component types should follow the same "no outer alias of resource types" rule as component definitions, and thus attempting to define the component type used to import c should fail validation (even before getting to the import definition). The rationale I think is: a component definition could not possibly match the type of c, given that any candidate component definition is not able to refer to r (b/c they're not allowed to outer alias resource types). Incidentally, this directly contradicts the example on line 976 of Text.md atm and several WAST tests in test/, so this would be a spec/test change.

  2. alexcrichton commented on Nov 20, 2026

    @alexcrichton
    CollaboratorAuthor

    Makes sense to me yeah, and that's easy enough to implement and AFAIK this won't break much in practice since importing components or declaring component types like this is likely pretty rare

  3. lukewagner commented on Dec 1, 2026

    @lukewagner
    Member

    Ok, (finally) written up in #776.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions