WebAssembly / gc

Branch of the spec repo scoped to discussion of GC integration in WebAssembly
https://webassembly.github.io/gc/
Other
992 stars 71 forks source link

Fix an example code for ref.cast in MVP.md #527

Closed tanishiking closed 7 months ago

tanishiking commented 7 months ago

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 https://github.com/WebAssembly/gc/commit/0ba84fb5f993348fc3eb052968bd869aa7bc3875)


Please let me know if I misunderstand something :)