From 871bf6d1d76e8af3c51b47f77875dfe695904bbe Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 12 Oct 2022 08:14:21 -0700 Subject: [Wasm GC] Fix the intersection of a bottom type null (#5128) When the heap types are not subtypes of each other, but a null is possible, the intersection exists and is a null. That null must be the shared bottom type. --- src/ir/possible-contents.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 8349939e1..cd8bd1516 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -195,11 +195,17 @@ void PossibleContents::intersectWithFullCone(const PossibleContents& other) { } // If the heap types are not compatible then they are in separate hierarchies - // and there is no intersection. + // and there is no intersection, aside from possibly a null of the bottom + // type. auto isSubType = HeapType::isSubType(heapType, otherHeapType); auto otherIsSubType = HeapType::isSubType(otherHeapType, heapType); if (!isSubType && !otherIsSubType) { - value = None(); + if (nullability == Nullable && + heapType.getBottom() == otherHeapType.getBottom()) { + value = Literal::makeNull(heapType.getBottom()); + } else { + value = None(); + } return; } -- cgit v1.2.3