Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support type annotation in WAC #57

Open
salmans opened this issue Feb 29, 2024 · 2 comments
Open

Support type annotation in WAC #57

salmans opened this issue Feb 29, 2024 · 2 comments

Comments

@salmans
Copy link

salmans commented Feb 29, 2024

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.

@peterhuene
Copy link
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.

@peterhuene
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants