WebAssembly / WebAssembly/wabt
GC branch: wat2wasm errors with order of local variables of struct or array reference type
Open
@binji is already working on this.
Since Jun 30, 2020.
- Dominant language
- C++
- Stars
- 8.1k
- Forks
- 827
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 18
Description
Using wat2wasm --enable-gc on the current WASM GC branch (https://github.com/WebAssembly/wabt/tree/19e51dbb3ccd2e1586f7aeb49f2f0f0c78169423), I get these errors:
problem.wat:11:4: error: type mismatch in local.set, expected [ref 1] but got [ref 0]
(local.set $new_obj)
^^^^^^^^^
problem.wat:13:4: error: type mismatch in implicit return, expected [ref 0] but got [ref 1]
(local.get $new_obj)
^^^^^^^^^
A fairly short example that exhibits the problem is this:
(module
(type $value (struct (field i32)))
(type $block_contents (array (mut anyref)))
(func $I_fail (param $obj (ref $value)) (result (ref $value))
(local $x (ref $block_contents))
(local $new_obj (ref $value))
(local.get $obj)
(local.set $new_obj)
(local.get $new_obj)
)
(func $I_am_ok (param $obj (ref $value)) (result (ref $value))
(local $new_obj (ref $value))
(local $x (ref $block_contents))
(local.get $obj)
(local.set $new_obj)
(local.get $new_obj)
)
)
Function $I_fail has the errors while $I_am_ok does not give errors. The only difference is the order of local variables. When I replace the type of local variable $x to be i32 or anyref in function $I_fail, there are no errors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.