Debian Codegraph @

tests/cli/function-references/return-call.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 ;; Test that various return calls must exactly match the callee's returns, not
4 ;; simply leave the operand stack in a state where a `call; return` would
5 ;; otherwise be valid, but with some dangling stack values. Those dangling stack
6 ;; values are valid for regular calls, but not for return calls.
7
8 (assert_invalid
9 (module
10 (func $f (result i32 i32) unreachable)
11 (func (result i32)
12 return_call $f
13 )
14 )
15 "type mismatch: current function requires result type [i32] but callee returns [i32 i32]"
16 )
17
18 (assert_invalid
19 (module
20 (type $ty (func (result i32 i32)))
21 (import "env" "table" (table $table 0 funcref))
22 (func (param i32) (result i32)
23 local.get 0
24 return_call_indirect $table (type $ty)
25 )
26 )
27 "type mismatch: current function requires result type [i32] but callee returns [i32 i32]"
28 )
29
30 (assert_invalid
31 (module
32 (type $ty (func (result i32 i32)))
33 (func (param funcref) (result i32)
34 local.get 0
35 return_call_ref $ty
36 )
37 )
38 "type mismatch: expected (ref null $type), found funcref"
39 )