Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ml-proto/test/br.wast
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,26 @@
(module (func $large-label (br 0x100000001)))
"unknown label"
)

;; Test that the value operand of br matches the result type of the block
;; it branches to, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32)
(drop
(block $green
(br $green (get_local $x))
(get_local $y)))))
"type mismatch")

;; Test that the value operand of br matches the result type of other
;; branches to the same block, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32)
(drop
(block $green
(br $green (get_local $x))
(br $green (get_local $y))
(get_local $x)))))
"type mismatch")
22 changes: 22 additions & 0 deletions ml-proto/test/br_if.wast
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,25 @@
"unknown label"
)

;; Test that the value operand of br_if matches the result type of the block
;; it branches to, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32) (param $cond i32)
(drop
(block $green
(br_if $green (get_local $x) (get_local $cond))
(get_local $y)))))
"type mismatch")

;; Test that the value operand of br_if matches the result type of other
;; branches to the same block, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32) (param $cond i32)
(drop
(block $green
(br_if $green (get_local $x) (get_local $cond))
(br_if $green (get_local $y) (get_local $cond))
(get_local $x)))))
"type mismatch")
22 changes: 22 additions & 0 deletions ml-proto/test/br_table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1385,3 +1385,25 @@
"unknown label"
)

;; Test that the value operand of br_table matches the result type of the block
;; it branches to, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32) (param $index i32)
(drop
(block $green
(br_table $green $green (get_local $x) (get_local $index))
(get_local $y)))))
"type mismatch")

;; Test that the value operand of br_table matches the result type of other
;; branches to the same block, even if the result of the block is dropped.
(assert_invalid
(module
(func $bar (param $x i32) (param $y f32) (param $index i32)
(drop
(block $green
(br_table $green $green (get_local $x) (get_local $index))
(br_table $green $green (get_local $y) (get_local $index))
(get_local $x)))))
"type mismatch")
10 changes: 10 additions & 0 deletions ml-proto/test/typecheck.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
;; if condition
(assert_invalid (module (func (if (f32.const 0) (nop) (nop)))) "type mismatch")

;; if arms
(assert_invalid
(module
(func $foo (param $x i32) (param $y f32) (param $cond i32)
(drop
(if (get_local $cond)
(get_local $y)
(get_local $x)))))
"type mismatch")

;; br_if condition
(assert_invalid (module (func (block (br_if 0 (f32.const 0))))) "type mismatch")

Expand Down