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) {
3979
3979
}
3980
3980
shouldBeTrue (curr->type .isExact (), curr, " cont.new should be exact" );
3981
3981
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 ),
3984
3992
curr,
3985
- " cont.new must be annotated with a continuation type " );
3993
+ " cont.new function reference must be a subtype " );
3986
3994
}
3987
3995
3988
3996
void FunctionValidator::visitContBind (ContBind* curr) {
Original file line number Diff line number Diff line change 242
242
(type $c2 (cont $f2 ))
243
243
)
244
244
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
+
245
265
;; Simple state example
246
266
247
267
(module $state
You can’t perform that action at this time.
0 commit comments