forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasmparser: Fix behavior of branching to labels and subtyping
Addresses issues discussed in WebAssembly/gc#516
- Loading branch information
Showing
4 changed files
with
72 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,31 @@ | ||
;; https://github.com/WebAssembly/gc/issues/516 | ||
|
||
(assert_invalid | ||
(module | ||
(func (param anyref) (result anyref) | ||
ref.null struct | ||
local.get 0 | ||
;; The label pushes an anyref, even though we really have a structref. | ||
br_on_null 0 | ||
drop | ||
br_on_cast_fail 0 structref structref | ||
) | ||
) | ||
"type mismatch: expected structref, found anyref" | ||
) | ||
|
||
(assert_invalid | ||
(module | ||
(func (param anyref) (result anyref) | ||
ref.null struct | ||
;; Adding an `unreachable` shouldn't change the fact that the `br_on_null` | ||
;; pushes an `anyref` and the `br_on_cast_fail` expects a `structref`. | ||
unreachable | ||
local.get 0 | ||
br_on_null 0 | ||
drop | ||
br_on_cast_fail 0 structref structref | ||
) | ||
) | ||
"type mismatch: expected structref, found anyref" | ||
) |
This file contains 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,11 @@ | ||
(module | ||
(func (export "f") | ||
f32.const 1.0 | ||
f32.const 2.0 | ||
br 0 | ||
i32.add | ||
drop | ||
) | ||
) | ||
|
||
(assert_trap (invoke "f") "unreachable") |
This file contains 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,11 @@ | ||
(module | ||
(type (;0;) (func)) | ||
(func (;0;) (type 0) | ||
f32.const 0x1p+0 (;=1;) | ||
f32.const 0x1p+1 (;=2;) | ||
br 0 (;@0;) | ||
i32.add | ||
drop | ||
) | ||
(export "f" (func 0)) | ||
) |