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 an example code for ref.cast in MVP.md #527

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

tanishiking
Copy link
Contributor

@tanishiking tanishiking commented Feb 25, 2024

The first argument for ref.cast should be a reference type. However, the code example in MVP.md seems to have a heaptype.
(Assuming the $C is defined as follows based on the context)

(module
  (type $A (sub (struct)))
  (type $B (sub $A (struct (field i32))))
  (type $C (sub $B (struct (field i32 i32))))
  (func $castBtoC (param $x (ref $B)) (result (ref $C))
    (ref.cast $C (local.get $x))
  )
)
$ wasm -d test.wat
test.wat:6.15-6.17: syntax error: unexpected token

(Where wasm is a reference interpreter built from 0ba84fb)


Please let me know if I misunderstand something :)

The first operand for `ref.cast` should be a reference type.
However, the code example in `MVP.md` seems to have a heaptype
which is invalid.
(Assuming the `$C` is defined as follows based on the context)

```
(module
  (type $A (sub (struct)))
  (type $B (sub $A (struct (field i32))))
  (type $C (sub $B (struct (field i32 i32))))
  (func $castBtoC (param $x (ref $B)) (result (ref $C))
    (ref.cast $C (local.get $x))
  )
)
```

```
$ wasm -d test.wat
test.wat:6.15-6.17: syntax error: unexpected token
```

(Where `wasm` is a reference interpreter built from
WebAssembly@0ba84fb)
Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (Oversight when we last tweaked the syntax.)

@rossberg rossberg merged commit 60edc79 into WebAssembly:main Feb 26, 2024
@tanishiking tanishiking deleted the fix-ref-cast-mvp branch February 26, 2024 14:03
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