summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-type.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index cf68d92e9..f98077961 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -521,8 +521,21 @@ bool Type::isSubType(Type left, Type right) {
return true;
}
if (left.isRef() && right.isRef()) {
- return right == Type::anyref ||
- (left == Type::i31ref && right == Type::eqref);
+ // Everything is a subtype of anyref.
+ if (right == Type::anyref) {
+ return true;
+ }
+ // Various things are subtypes of eqref.
+ if ((left == Type::i31ref || left.getHeapType().isArray() ||
+ left.getHeapType().isStruct()) &&
+ right == Type::eqref) {
+ return true;
+ }
+ // All typed function signatures are subtypes of funcref.
+ if (left.getHeapType().isSignature() && right == Type::funcref) {
+ return true;
+ }
+ return false;
}
if (left.isTuple() && right.isTuple()) {
if (left.size() != right.size()) {