Skip to content

Commit 159f680

Browse files
committed
handle soon-to-be-invalid types
1 parent 752061c commit 159f680

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/passes/Unsubtyping.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,11 @@ struct Unsubtyping : Pass {
849849
// Add all the edges. Don't worry about duplicating existing edges because
850850
// checking whether they're necessary now would be about as expensive as
851851
// discarding them later.
852-
noteSubtype(*sub, *super);
852+
// TODO: We will be able to assume this once we update the descriptor
853+
// validation rules.
854+
if (HeapType::isSubType(*sub, *super)) {
855+
noteSubtype(*sub, *super);
856+
}
853857
noteSubtype(*subDesc, *superDesc);
854858
noteDescriptor(*super, *superDesc);
855859
noteDescriptor(*sub, *subDesc);

test/lit/passes/unsubtyping-desc.wast

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,3 +1086,22 @@
10861086
)
10871087
)
10881088
)
1089+
1090+
;; This will be invalid soon, but in the meantime we should not be confused when
1091+
;; the types described by two related descriptors are unrelated.
1092+
(module
1093+
(rec
1094+
;; CHECK: (rec
1095+
;; CHECK-NEXT: (type $A (descriptor $super (struct)))
1096+
(type $A (descriptor $super (struct)))
1097+
;; CHECK: (type $B (descriptor $sub (struct)))
1098+
(type $B (descriptor $sub (struct)))
1099+
;; CHECK: (type $super (sub (describes $A (struct))))
1100+
(type $super (sub (describes $A (struct))))
1101+
;; CHECK: (type $sub (sub $super (describes $B (struct))))
1102+
(type $sub (sub $super (describes $B (struct))))
1103+
)
1104+
;; CHECK: (global $public (ref null $B) (ref.null none))
1105+
(global $public (export "public") (ref null $B) (ref.null none))
1106+
)
1107+
;; CHECK: (export "public" (global $public))

0 commit comments

Comments
 (0)