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

fix type checking WAT examples #344

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

rvolosatovs
Copy link
Contributor

@rvolosatovs rvolosatovs commented Apr 18, 2024

While studying the explainer and working on #336 , I found out that the example type checking WAT is not valid.
I've quickly tested this by modifying a test case in Wasmtime with the following WAT (it appears that inverted alias form as defined in

Lastly, for symmetry with [imports][func-import-abbrev], aliases can be written
in an inverted form that puts the sort first:
```wasm
(func $f (import "i" "f") ...type...) ≡ (import "i" "f" (func $f ...type...)) (WebAssembly 1.0)
(func $f (alias export $i "f")) ≡ (alias export $i "f" (func $f))
(core module $m (alias export $i "m")) ≡ (alias export $i "m" (core module $m))
(core func $f (alias core export $i "f")) ≡ (alias core export $i "f" (core func $f))
```
is not supported by whatever is parsing WAT in Wasmtime)

(component $A
    (type $ListString1 (list string))
    (type $ListListString1 (list $ListString1))
    (type $ListListString2 (list $ListString1))
    (component $B
      (type $ListString3 (list string))
      (type $ListListString3 (list $ListString3))
      (alias outer $A $ListString (type $ListString4))
      (type $ListListString4 (list $ListString4))
      (alias outer $A $ListString2 (type $ListListString5))
    )
)

Which failed with:

Error: unknown type: failed to find name `$ListString`
     --> <anon>:10:39
      |
   10 |                       (alias outer $A $ListString (type $ListString4))

as expected

Proposed version:

(component $A
  (type $ListString1 (list string))
  (type $ListListString1 (list $ListString1))
  (type $ListListString2 (list $ListString1))
  (component $B
    (type $ListString2 (list string))
    (type $ListListString3 (list $ListString2))
    (alias outer $A $ListString1 (type $ListString3))
    (type $ListListString4 (list $ListString3))
    (alias outer $A $ListListString2 (type $ListListString5))
  )
)

@rvolosatovs rvolosatovs changed the title fix type checking WAT example fix type checking WAT examples Apr 18, 2024
@lukewagner
Copy link
Member

Oops, I'm sorry, I missed the notification for this PR a while back. Thanks!

@lukewagner lukewagner merged commit 92b77a3 into WebAssembly:main Apr 30, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants