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
4 changes: 2 additions & 2 deletions interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ let check_resume_table (c : context) ts2 (xys : (idx * hdl) list) at =
let FuncT (ts3, ts4) = func_type_of_tag_type c (tag c x1) x1.at in
let ts' = label c x2 in
(match Lib.List.last_opt ts' with
| Some (RefT (nul', ht)) ->
| Some (RefT (nul', ((VarHT _ | DefHT _) as ht))) ->
let ct = cont_type_of_heap_type c ht x2.at in
let ft' = func_type_of_cont_type c ct x2.at in
require (match_func_type c.types (FuncT (ts4, ts2)) ft') x2.at
"type mismatch in continuation type";
match_stack c (ts3 @ [RefT (nul', ht)]) ts' x2.at
| _ ->
error at
("type mismatch: instruction requires continuation reference type" ^
("type mismatch: instruction requires concrete continuation reference type" ^
" but label has " ^ string_of_result_type ts'))
| OnSwitch ->
let FuncT (ts3, ts4) = func_type_of_tag_type c (tag c x1) x1.at in
Expand Down
42 changes: 42 additions & 0 deletions test/core/stack-switching/cont.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1141,3 +1141,45 @@
(func (param $k (ref $ct))
(switch $ct $t)))
"type mismatch in switch tag")

;; Synthesized from https://github.com/WebAssembly/stack-switching/issues/117
(assert_invalid
(module
(type $ft (func))
(type $ct (cont $ft))
(tag $t)

(func
(block $on_t (result (ref cont))
(resume $ct (on $t $on_t) (cont.new $ct (ref.null $ft)))
(unreachable)
)
(drop)
))
"type mismatch: instruction requires concrete continuation reference type but label has [(ref cont)]")

(assert_invalid
(module
(type $ft (func))
(type $ct (cont $ft))
(tag $t)

(func
(block $on_t (result (ref nocont))
(resume $ct (on $t $on_t) (cont.new $ct (ref.null $ft)))
(unreachable)
)
(drop)
))
"type mismatch: instruction requires concrete continuation reference type but label has [(ref nocont)]")

;; https://github.com/WebAssembly/stack-switching/issues/117#issuecomment-2908974084
(module
(type $f (func))
(type $c (sub (cont $f)))
(tag $e)
(func (param $c (ref $c))
(local.get $c)
(resume $c)
)
)