File tree Expand file tree Collapse file tree 2 files changed +56
-7
lines changed
Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Original file line number Diff line number Diff line change @@ -561,13 +561,16 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
561561 }
562562 processResumeHandlers (
563563 curr->cont ->type , curr->handlerTags , curr->handlerBlocks );
564- // The types we use to create the exception package must remain subtypes of
565- // the types expected by the exception tag.
566- auto params =
567- self ()->getModule ()->getTag (curr->tag )->type .getSignature ().params ;
568- assert (curr->operands .size () == params.size ());
569- for (Index i = 0 ; i < curr->operands .size (); ++i) {
570- self ()->noteSubtype (curr->operands [i], params[i]);
564+
565+ if (curr->tag ) {
566+ // The types we use to create the exception package must remain subtypes
567+ // of the types expected by the exception tag.
568+ auto params =
569+ self ()->getModule ()->getTag (curr->tag )->type .getSignature ().params ;
570+ assert (curr->operands .size () == params.size ());
571+ for (Index i = 0 ; i < curr->operands .size (); ++i) {
572+ self ()->noteSubtype (curr->operands [i], params[i]);
573+ }
571574 }
572575 }
573576 void visitStackSwitch (StackSwitch* curr) {
Original file line number Diff line number Diff line change 478478 )
479479 )
480480)
481+
482+ ;; Test we do not error on resume_throw_ref. It adds no subtyping constraints
483+ ;; between declared types besides those from the handlers.
484+ (module
485+ ;; CHECK: (rec
486+ ;; CHECK-NEXT: (type $f (func))
487+
488+ ;; CHECK: (type $k (cont $f))
489+
490+ ;; CHECK: (elem declare func $no_handler)
491+
492+ ;; CHECK: (tag $e0 (type $f))
493+ (tag $e0 )
494+
495+ (type $f (func ))
496+ (type $k (cont $f ))
497+
498+ ;; CHECK: (func $no_handler (type $f)
499+ ;; CHECK-NEXT: (unreachable)
500+ ;; CHECK-NEXT: )
501+ (func $no_handler
502+ (unreachable )
503+ )
504+
505+ ;; CHECK: (func $throw_unhandled_ref (type $f)
506+ ;; CHECK-NEXT: (resume_throw_ref $k
507+ ;; CHECK-NEXT: (block $h (result (ref exn))
508+ ;; CHECK-NEXT: (try_table (catch_ref $e0 $h)
509+ ;; CHECK-NEXT: (throw $e0)
510+ ;; CHECK-NEXT: )
511+ ;; CHECK-NEXT: (unreachable)
512+ ;; CHECK-NEXT: )
513+ ;; CHECK-NEXT: (cont.new $k
514+ ;; CHECK-NEXT: (ref.func $no_handler)
515+ ;; CHECK-NEXT: )
516+ ;; CHECK-NEXT: )
517+ ;; CHECK-NEXT: )
518+ (func $throw_unhandled_ref
519+ (block $h (result exnref)
520+ (try_table (catch_ref $e0 $h ) (throw $e0 ))
521+ (unreachable )
522+ )
523+ (resume_throw_ref $k (cont.new $k (ref.func $no_handler )))
524+ )
525+ )
526+
You can’t perform that action at this time.
0 commit comments