Skip to content

Commit 486f558

Browse files
committed
Fix assertion failure for non-concrete continuation types
This patch fixes the assertion failures listed in issue #117 that were not fixed prior to closing the issue.
1 parent 03c6e4c commit 486f558

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

interpreter/valid/valid.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,15 @@ let check_resume_table (c : context) ts2 (xys : (idx * hdl) list) at =
441441
let FuncT (ts3, ts4) = func_type_of_tag_type c (tag c x1) x1.at in
442442
let ts' = label c x2 in
443443
(match Lib.List.last_opt ts' with
444-
| Some (RefT (nul', ht)) ->
444+
| Some (RefT (nul', ((VarHT _ | DefHT _) as ht))) ->
445445
let ct = cont_type_of_heap_type c ht x2.at in
446446
let ft' = func_type_of_cont_type c ct x2.at in
447447
require (match_func_type c.types (FuncT (ts4, ts2)) ft') x2.at
448448
"type mismatch in continuation type";
449449
match_stack c (ts3 @ [RefT (nul', ht)]) ts' x2.at
450450
| _ ->
451451
error at
452-
("type mismatch: instruction requires continuation reference type" ^
452+
("type mismatch: instruction requires concrete continuation reference type" ^
453453
" but label has " ^ string_of_result_type ts'))
454454
| OnSwitch ->
455455
let FuncT (ts3, ts4) = func_type_of_tag_type c (tag c x1) x1.at in

test/core/stack-switching/cont.wast

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,3 +1141,45 @@
11411141
(func (param $k (ref $ct))
11421142
(switch $ct $t)))
11431143
"type mismatch in switch tag")
1144+
1145+
;; Synthesized from https://github.com/WebAssembly/stack-switching/issues/117
1146+
(assert_invalid
1147+
(module
1148+
(type $ft (func))
1149+
(type $ct (cont $ft))
1150+
(tag $t)
1151+
1152+
(func
1153+
(block $on_t (result (ref cont))
1154+
(resume $ct (on $t $on_t) (cont.new $ct (ref.null $ft)))
1155+
(unreachable)
1156+
)
1157+
(drop)
1158+
))
1159+
"type mismatch: instruction requires concrete continuation reference type but label has [(ref cont)]")
1160+
1161+
(assert_invalid
1162+
(module
1163+
(type $ft (func))
1164+
(type $ct (cont $ft))
1165+
(tag $t)
1166+
1167+
(func
1168+
(block $on_t (result (ref nocont))
1169+
(resume $ct (on $t $on_t) (cont.new $ct (ref.null $ft)))
1170+
(unreachable)
1171+
)
1172+
(drop)
1173+
))
1174+
"type mismatch: instruction requires concrete continuation reference type but label has [(ref nocont)]")
1175+
1176+
;; https://github.com/WebAssembly/stack-switching/issues/117#issuecomment-2908974084
1177+
(module
1178+
(type $f (func))
1179+
(type $c (sub (cont $f)))
1180+
(tag $e)
1181+
(func (param $c (ref $c))
1182+
(local.get $c)
1183+
(resume $c)
1184+
)
1185+
)

0 commit comments

Comments
 (0)