From 82c05244ca100f7bc99c5812e8ddd3155083b639 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 16 Oct 2024 08:35:36 -0700 Subject: [PATCH] fix --- src/ir/subtype-exprs.h | 8 ++++++- test/lit/passes/unsubtyping.wast | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/ir/subtype-exprs.h b/src/ir/subtype-exprs.h index 640240df932..1895c856ae1 100644 --- a/src/ir/subtype-exprs.h +++ b/src/ir/subtype-exprs.h @@ -249,7 +249,13 @@ struct SubtypingDiscoverer : public OverriddenVisitor { self()->noteSubtype(body, curr); } } - void visitTryTable(TryTable* curr) { self()->noteSubtype(curr->body, curr); } + void visitTryTable(TryTable* curr) { + self()->noteSubtype(curr->body, curr); + for (Index i = 0; i < curr->catchTags.size(); i++) { + self()->noteSubtype(curr->sentTypes[i], + self()->findBreakTarget(curr->catchDests[i])); + } + } void visitThrow(Throw* curr) { Type params = self()->getModule()->getTag(curr->tag)->sig.params; assert(params.size() == curr->operands.size()); diff --git a/test/lit/passes/unsubtyping.wast b/test/lit/passes/unsubtyping.wast index aa4af720bf3..97a2dd59ab8 100644 --- a/test/lit/passes/unsubtyping.wast +++ b/test/lit/passes/unsubtyping.wast @@ -1779,3 +1779,39 @@ ) ) ) + +;; try_table +(module + (rec + ;; CHECK: (rec + ;; CHECK-NEXT: (type $super (sub (func))) + (type $super (sub (func))) + ;; CHECK: (type $sub (sub $super (func))) + (type $sub (sub $super (func))) + ) + + ;; CHECK: (type $2 (func (result (ref $super)))) + + ;; CHECK: (type $3 (func (param (ref $sub)))) + + ;; CHECK: (type $4 (func (param (ref $sub)))) + + ;; CHECK: (tag $tag (param (ref $sub))) + (tag $tag (param (ref $sub))) + + ;; CHECK: (func $test (type $2) (result (ref $super)) + ;; CHECK-NEXT: (block $label (result (ref $sub)) + ;; CHECK-NEXT: (try_table (catch $tag $label) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test (result (ref $super)) + (block $label (result (ref $super)) + ;; Sending the contents of $tag to $label cause us to require $sub <: $super + (try_table (catch $tag $label) + (unreachable) + ) + ) + ) +)