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
14 changes: 14 additions & 0 deletions test/core/return_call.wast
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
(func (export "type-f64-i64-to-i32-f32") (param f64 i64) (result i32 f32)
(return_call $swizzle (local.get 0) (local.get 1))
)

;; Result subtyping
(type $t (func))
(func $f (result (ref null $t)) (ref.null $t))
(func (export "type-funcref") (result funcref) (return_call $f))
)

(assert_return (invoke "type-i32") (i32.const 0x132))
Expand Down Expand Up @@ -134,6 +139,7 @@
(assert_return (invoke "odd" (i64.const 999_999)) (i32.const 44))
(assert_return (invoke "tailprint_i32_f32" (i32.const 5) (f32.const 91.0)))
(assert_return (invoke "type-f64-i64-to-i32-f32" (f64.const 4.2) (i64.const 99)) (i32.const 99) (f32.const 4.2))
(assert_return (invoke "type-funcref") (ref.null func))

;; Invalid typing

Expand All @@ -151,6 +157,14 @@
)
"type mismatch"
)
(assert_invalid
(module
(type $t (func))
(func $type-ref-vs-funcref (result (ref null $t)) (return_call 1))
(func (result funcref) (unreachable))
)
"type mismatch"
)

(assert_invalid
(module
Expand Down
19 changes: 19 additions & 0 deletions test/core/return_call_indirect.wast
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@
(func (export "call_mpmr") (param f64 i64) (result i32 f32)
(return_call_indirect $tab4 (param f64 i64) (result i32 f32) (local.get 0) (local.get 1) (i32.const 1))
)

;; Result subtyping
(type $t (func))
(func $f (result (ref null $t)) (ref.null $t))
(table $tab5 funcref (elem $f))
(func (export "type-funcref") (result funcref)
(return_call_indirect $tab5 (result (ref null $t)) (i32.const 0))
)
)

(assert_return (invoke "type-i32") (i32.const 0x132))
Expand Down Expand Up @@ -294,6 +302,7 @@

(assert_return (invoke "call_tailprint" (i32.const 5) (f32.const 91.0)))
(assert_return (invoke "call_mpmr" (f64.const 4.2) (i64.const 99)) (i32.const 99) (f32.const 4.2))
(assert_return (invoke "type-funcref") (ref.null func))

;; Invalid syntax

Expand Down Expand Up @@ -447,6 +456,16 @@
)
"type mismatch"
)
(assert_invalid
(module
(type $t (func))
(table 0 funcref)
(func $type-ref-vs-funcref (result (ref null $t))
(return_call_indirect (result funcref) (i32.const 0))
)
)
"type mismatch"
)

(assert_invalid
(module
Expand Down
Loading