diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index d998262106d..954c76f85b0 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -121,8 +121,8 @@ struct ExecutionResults { } bool areEqual(Literal a, Literal b) { - if (a.type != b.type) { - std::cout << "types not identical! " << a << " != " << b << '\n'; + if (!Type::isSubType(a.type, b.type) && !Type::isSubType(b.type, a.type)) { + std::cout << "types not compatible! " << a << " != " << b << '\n'; return false; } if (a.type.isRef()) { @@ -133,6 +133,9 @@ struct ExecutionResults { // a separate instance of each) - we can't really identify an identical // reference between such things. We can only compare things structurally, // for which we compare the types. + // Another issue is that the same module, when passed through --roundtrip, + // will end up with a type that does not compare equally as we do not + // currently globally canonicalize recursive types. return true; } if (a != b) { diff --git a/test/passes/roundtrip_fuzz-exec_all-features.txt b/test/passes/roundtrip_fuzz-exec_all-features.txt new file mode 100644 index 00000000000..d025f8de566 --- /dev/null +++ b/test/passes/roundtrip_fuzz-exec_all-features.txt @@ -0,0 +1,13 @@ +[fuzz-exec] calling foo +[fuzz-exec] note result: foo => funcref(null) +(module + (type $A (func (result (ref null $A)))) + (type $none_=>_funcref (func (result funcref))) + (export "foo" (func $0)) + (func $0 (result funcref) + (ref.null $A) + ) +) +[fuzz-exec] calling foo +[fuzz-exec] note result: foo => funcref(null) +[fuzz-exec] comparing foo diff --git a/test/passes/roundtrip_fuzz-exec_all-features.wast b/test/passes/roundtrip_fuzz-exec_all-features.wast new file mode 100644 index 00000000000..fb6679e723d --- /dev/null +++ b/test/passes/roundtrip_fuzz-exec_all-features.wast @@ -0,0 +1,7 @@ +(module + (type $A (func (result (ref null $A)))) + (func "foo" (result funcref) + (ref.null $A) + ) +) +