File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,14 @@ std::string TypesToString(const TypeVector& types,
3030 }
3131
3232 for (size_t i = 0 ; i < types.size (); ++i) {
33- result += types[i].GetName ();
33+ Type ty = types[i];
34+ // NOTE: Reference (and GetName) is also used by (e.g.) objdump, which does
35+ // not apply validation. do this here so as to not break that.
36+ if (ty == Type::Reference && ty.GetReferenceIndex () == kInvalidIndex ) {
37+ result += " reference" ;
38+ } else {
39+ result += types[i].GetName ();
40+ }
3441 if (i < types.size () - 1 ) {
3542 result += " , " ;
3643 }
@@ -812,18 +819,10 @@ Result TypeChecker::OnRefNullExpr(Type type) {
812819Result TypeChecker::OnRefIsNullExpr () {
813820 Type type;
814821 Result result = PeekType (0 , &type);
815- if (!(type == Type::Any || type.IsRef ())) {
816- TypeVector actual;
817- if (Succeeded (result)) {
818- actual.push_back (type);
819- }
820- std::string message =
821- " type mismatch in ref.is_null, expected reference but got " +
822- TypesToString (actual);
823- PrintError (" %s" , message.c_str ());
824- result = Result::Error;
822+ if (!type.IsRef ()) {
823+ type = Type::Reference;
825824 }
826- result |= DropTypes ( 1 );
825+ result |= PopAndCheck1Type (type, " ref.is_null " );
827826 PushType (Type::I32);
828827 return result;
829828}
Original file line number Diff line number Diff line change 44init(externref:1) =>
55deinit() =>
66out/test/spec/ref_is_null.wast:52: assert_invalid passed:
7- out/test/spec/ref_is_null/ref_is_null.1.wasm:000001b: error: type mismatch in ref.is_null, expected reference but got [i32]
7+ out/test/spec/ref_is_null/ref_is_null.1.wasm:000001b: error: type mismatch in ref.is_null, expected [ reference] but got [i32]
88 000001b: error: OnRefIsNullExpr callback failed
99out/test/spec/ref_is_null.wast:56: assert_invalid passed:
10+ out/test/spec/ref_is_null/ref_is_null.2.wasm:0000018: error: type mismatch in ref.is_null, expected [reference] but got []
1011 0000018: error: OnRefIsNullExpr callback failed
111216/16 tests passed.
1213;;; STDOUT ;;)
You can’t perform that action at this time.
0 commit comments