diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index 9c07c003..291a1b4f 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -441,7 +441,7 @@ 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 @@ -449,7 +449,7 @@ let check_resume_table (c : context) ts2 (xys : (idx * hdl) list) at = 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 diff --git a/test/core/stack-switching/cont.wast b/test/core/stack-switching/cont.wast index 81007cfc..5725eb5d 100644 --- a/test/core/stack-switching/cont.wast +++ b/test/core/stack-switching/cont.wast @@ -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) + ) +)