Skip to content

Commit 013cf5d

Browse files
committed
Test return_call*s to callees that return more values than the caller does
While a `call $f; return` sequence where `$f` returns more values than its caller is valid so long as the tail of `$f`'s returns match the caller's returns, however that situation is not valid for `return_call $f`. Tail callees must return the exact same number of results as the caller, not more. This case was not previously exercised in any of the spec tests. Procedural note: I am adding all these tests to the function-references proposal to avoid needing to make multiple PRs to multiple repos because `return_call_ref` was not introduced until this proposal.
1 parent 8475cff commit 013cf5d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

test/core/return_call.wast

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,15 @@
188188
)
189189
"type mismatch"
190190
)
191-
191+
(assert_invalid
192+
(module
193+
(func $f (result i32 i32) unreachable)
194+
(func (result i32)
195+
return_call $f
196+
)
197+
)
198+
"type mismatch"
199+
)
192200

193201
;; Unbound function
194202

test/core/return_call_indirect.wast

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,17 @@
508508
)
509509
"type mismatch"
510510
)
511-
511+
(assert_invalid
512+
(module
513+
(type $ty (func (result i32 i32)))
514+
(import "env" "table" (table $table 0 funcref))
515+
(func (param i32) (result i32)
516+
local.get 0
517+
return_call_indirect $table (type $ty)
518+
)
519+
)
520+
"type mismatch"
521+
)
512522

513523
;; Unbound type
514524

test/core/return_call_ref.wast

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,14 @@
374374
)
375375
"type mismatch"
376376
)
377+
378+
(assert_invalid
379+
(module
380+
(type $ty (func (result i32 i32)))
381+
(func (param funcref) (result i32)
382+
local.get 0
383+
return_call_ref $ty
384+
)
385+
)
386+
"type mismatch"
387+
)

0 commit comments

Comments
 (0)