Repository navigation
Make WIT decoded from components match them - #2851
Open
sansmoraxz wants to merge 9 commits into
Open
sansmoraxz wants to merge 9 commits into
sansmoraxz wants to merge 9 commits into
Conversation
A world's `use` of an interface's type is encoded as a type import, but a component's functions can also refer to an imported instance's type directly. Decoding such a function gave the world no `use` for the type, and its WIT, such as `import f: func(x: t);`, didn't parse. The decoded world now gets the `use`s its functions need. It's an error if another item in the world already has the type's name.
A world exporting `a:b/i` and an interface that uses `a:b/i` through the imported `a:b/j` would give that interface both the imported and the exported `a:b/i`, which WIT rejects. Decoding accepted such a component and printed WIT that doesn't parse. Decoded worlds now go through the same export check as worlds parsed from WIT.
Decoding injected a package-docs section's docs and feature names as they were, so a feature name like `]x` or docs with a control code printed as WIT that doesn't parse.
Decoding injected a package-docs section's `@since` versions as they were, so one newer than the package's version, or in a package without a version, printed as WIT that doesn't parse.
`@unstable(feature = %func)` printed as `@unstable(feature = func)`, which doesn't parse.
Decoding failed on an interface whose `type t = own<r>` reused the anonymous `own<r>` of an earlier `list<own<r>>`, taking it for a `use` of an anonymous type. In a world the same encoding decoded as `type t = r`, an alias of the resource rather than a handle to it. Such a type is now defined as the anonymous type it reuses. In an interface, only when every named type it reaches belongs to that interface; anything else still has no WIT form and still errors.
Decoding merges every use of an interface into one, so an export of `a:x/k` with a function taking `a:x/l`'s `t`, which it neither defines nor `use`s, gave interface `k` that function. `component wit` printed WIT that doesn't parse, and encoding it failed later on. Named interfaces can now only refer to their own types and to types they `use` under those types' names. Unnamed interfaces are left alone, since they still encode and `wasm-compose` makes them.
Decoding merges a world's import and export of one interface, so an export that `use`s `a:x/l` gave the imported `a:x/k` a dependency on `a:x/l`, which the world only exports. WIT would import `a:x/l` for `k`, but the decoded world didn't, and encoding it failed later on.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is hopefully the last set of backports
Some components decoded fine, but
component witthen printed WIT that doesn't parse, or that failed when encoded again. Now each of these either decodes to valid WIT or returns an error saying what WIT can't express.Now accepted:
type t = own<r>afterlist<own<r>>.Now an error:
use.@sinceversions.Also fixed: the printer now escapes keyword feature names (
%func).