wac
wac copied to clipboard
Support type annotation in WAC
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.
Proposed syntax might be:
new-expr ::= 'new' package-name type-ascription? '{' instantiation-args '}'
type-ascription ::= ':' (id | package-path)
Constraints:
- The
idorpackage-pathmust name a world. - The result of the new expression must be a subtype of the given world.
- The ascribed type will be used for validation of the instantiation args.
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 {}.