Repository navigation
Error on single items WIT can't express instead of panicking #2815
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
Open
sansmoraxz
wants to merge
6
commits into
bytecodealliance:main
Choose a base branch
from
sansmoraxz:wit-decode/2-items
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+216
−52
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c1af872
wit-parser: error on component, instance and function types
sansmoraxz 701a620
wit-parser: error on functions named like an interface
sansmoraxz 4eb5cf0
wit-parser: error on types named like an interface
sansmoraxz f786e79
wit-parser: error on methods of a resource from another interface
sansmoraxz a32b584
wit-parser: error on component-type sections that aren't one world
sansmoraxz 0ae9aaa
wit-parser: look up a function's resource only for resource functions
sansmoraxz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
tests/cli/component-wit-custom-section-world-exports-instance.wat
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ;; FAIL: component wit % | ||
| ;; | ||
| ;; The custom section holds the binary of: | ||
| ;; | ||
| ;; (component (type $c (component (export "a:b/w" (instance)))) (export "w" (type $c))) | ||
|
|
||
| (module | ||
| (@custom "component-type:x" "\00\61\73\6d\0d\00\01\00\07\10\01\41\02\01\42\00\04\00\05\61\3a\62\2f\77\05\00\0b\07\01\00\01\77\03\00\00\00\16\0e\63\6f\6d\70\6f\6e\65\6e\74\2d\6e\61\6d\65\01\05\03\01\00\01\63") | ||
| ) | ||
4 changes: 4 additions & 0 deletions
4
tests/cli/component-wit-custom-section-world-exports-instance.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: decoding custom section component-type:x | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: export `a:b/w` is not a world |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ;; FAIL: component wit % | ||
| ;; | ||
| ;; The custom section holds the binary of: | ||
| ;; | ||
| ;; (component (type $c (component (import "a:b/c" (instance)) (export "a:b/w" (component)))) (export "w" (type $c))) | ||
|
|
||
| (module | ||
| (@custom "component-type:x" "\00\61\73\6d\0d\00\01\00\07\1d\01\41\04\01\42\00\03\00\05\61\3a\62\2f\63\05\00\01\41\00\04\00\05\61\3a\62\2f\77\04\01\0b\07\01\00\01\77\03\00\00\00\16\0e\63\6f\6d\70\6f\6e\65\6e\74\2d\6e\61\6d\65\01\05\03\01\00\01\63") | ||
| ) |
4 changes: 4 additions & 0 deletions
4
tests/cli/component-wit-custom-section-world-imports.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: decoding custom section component-type:x | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: expected an exported component type with no imports and one export |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ;; FAIL: component wit % | ||
| ;; | ||
| ;; The custom section holds the binary of: | ||
| ;; | ||
| ;; (component (type $c (component)) (export "x" (type $c))) | ||
|
|
||
| (module | ||
| (@custom "component-type:x" "\00\61\73\6d\0d\00\01\00\07\03\01\41\00\0b\07\01\00\01\78\03\00\00\00\16\0e\63\6f\6d\70\6f\6e\65\6e\74\2d\6e\61\6d\65\01\05\03\01\00\01\63") | ||
| ) |
4 changes: 4 additions & 0 deletions
4
tests/cli/component-wit-custom-section-world-no-export.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: decoding custom section component-type:x | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: expected an exported component type with no imports and one export |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (import "a:b/c" (func)) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: failed to decode function from import `a:b/c` | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: function `a:b/c` has an interface's name |
12 changes: 12 additions & 0 deletions
12
tests/cli/component-wit-implements-redefines-type-as-instance-type.wat
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (import "x" (implements "a:b/c") (instance | ||
| (type $t u32) | ||
| (export "t" (type (eq $t))) | ||
| )) | ||
| (import "y" (implements "a:b/c") (instance | ||
| (type $i (instance)) | ||
| (export "t" (type (eq $i))) | ||
| )) | ||
| ) |
4 changes: 4 additions & 0 deletions
4
tests/cli/component-wit-implements-redefines-type-as-instance-type.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: failed to decode WIT from import `y` | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: type `t` is a component, instance or function type |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (type $c (component)) | ||
| (import "t" (type (eq $c))) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: failed to decode type from export `t` | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: type `t` is a component, instance or function type |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (import "i" (instance | ||
| (type $f (func)) | ||
| (export "t" (type (eq $f))) | ||
| )) | ||
| ) |
5 changes: 5 additions & 0 deletions
5
tests/cli/component-wit-instance-exports-func-type.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: failed to decode WIT from import `i` | ||
|
|
||
| Caused by: | ||
| 0: failed to register type export 't' | ||
| 1: cannot represent this component in WIT: type `t` is a component, instance or function type |
8 changes: 8 additions & 0 deletions
8
tests/cli/component-wit-instance-type-with-interface-name.wat
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (import "i" (instance | ||
| (type (list u8)) | ||
| (export "a:b/c@1.0.0" (type (eq 0))) | ||
| )) | ||
| ) |
5 changes: 5 additions & 0 deletions
5
tests/cli/component-wit-instance-type-with-interface-name.wat.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: failed to decode WIT from import `i` | ||
|
|
||
| Caused by: | ||
| 0: failed to register type export 'a:b/c@1.0.0' | ||
| 1: cannot represent this component in WIT: type `a:b/c@1.0.0` doesn't have a plain name |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think technically this is supposed to be an invalid component, not just an invalid-WIT component. I think it's a bug in wasmparser's valiator that this is accepted |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (import "a:b/d" (instance $d | ||
| (export "r" (type (sub resource))) | ||
| )) | ||
| (alias export $d "r" (type $r)) | ||
| (import "a:b/e" (instance | ||
| (export "r" (type $x (eq $r))) | ||
| (export "[method]r.f" (func (param "self" (borrow $x)))) | ||
| )) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: failed to decode WIT from import `a:b/e` | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: function `[method]r.f` is not next to the definition of its resource `r` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ;; FAIL: component wit % | ||
|
|
||
| (component | ||
| (type (list u8)) | ||
| (import "a:b/c" (type (eq 0))) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| error: failed to decode type from export `a:b/c` | ||
|
|
||
| Caused by: | ||
| 0: cannot represent this component in WIT: type `a:b/c` doesn't have a plain name |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit wary of tests like this which are otherwise suitable for the text format but due to tooling limitations require the binary format. If you're up for it this might make sense as a new CLI flag to
wasm-tools component embedto create this component, but otherwise I think it's ok to drop the binary-style tests for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lemme see how complex this would be.
I have around 6 more PRs planned stacked on top of this.
If it looks like too much scope creep I should probably spawn out a new issue and tackle that as seperate PR.