File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -3979,10 +3979,18 @@ void FunctionValidator::visitContNew(ContNew* curr) {
39793979 }
39803980 shouldBeTrue (curr->type .isExact (), curr, " cont.new should be exact" );
39813981
3982- shouldBeTrue (curr->type .isContinuation () &&
3983- curr->type .getHeapType ().getContinuation ().type .isSignature (),
3982+ if (!shouldBeTrue (curr->type .isContinuation (),
3983+ curr,
3984+ " cont.new must be annotated with a continuation type" )) {
3985+ return ;
3986+ }
3987+
3988+ auto cont = curr->type .getHeapType ().getContinuation ();
3989+ assert (cont.type .isSignature ());
3990+
3991+ shouldBeTrue (HeapType::isSubType (curr->func ->type .getHeapType (), cont.type ),
39843992 curr,
3985- " cont.new must be annotated with a continuation type " );
3993+ " cont.new function reference must be a subtype " );
39863994}
39873995
39883996void FunctionValidator::visitContBind (ContBind* curr) {
Original file line number Diff line number Diff line change 242242 (type $c2 (cont $f2 ))
243243)
244244
245+ (assert_invalid
246+ (module
247+ (rec
248+ (type $fA (func ))
249+ (type $fB (func ))
250+ (type $cont (cont $fA ))
251+ )
252+ (elem declare func $b )
253+ (func $a
254+ (drop
255+ (cont.new $cont ;; expects a ref of $fA, not $fB
256+ (ref.func $b )
257+ )
258+ )
259+ )
260+ (func $b (type $fB )
261+ )
262+ )
263+ " type mismatch" )
264+
245265;; Simple state example
246266
247267(module $state
You can’t perform that action at this time.
0 commit comments