Skip to content

Support type annotation in WAC #57

Open

Description

@salmans

When instantiating a component, it's useful to allow the user to provide type annotation that fixes the component's expected imports and exports. For example, in the scenario described in #56, the type annotation can be used to suppress the unknown import error when the import is intended but is not present in the component's WIT, generated by witgen.

Activity

  1. peterhuene commented on Mar 4, 2024

    @peterhuene
    Member

    Proposed syntax might be:

    new-expr                ::= 'new' package-name type-ascription? '{' instantiation-args '}'
    type-ascription         ::= ':' (id | package-path)

    Constraints:

    1. The id or package-path must name a world.
    2. The result of the new expression must be a subtype of the given world.
    3. The ascribed type will be used for validation of the instantiation args.
  2. peterhuene commented on Mar 12, 2024

    @peterhuene
    Member

    The : delimiter might be confusing since this would be legal with the above grammar: new foo:bar:foo:bar/baz {}.

    Perhaps as instead of :, leading to new foo:bar as foo:bar/baz {}.

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