@@ -107,6 +107,23 @@ type exportable =
107107 | Global
108108 | Tag
109109
110+ let heaptype_eq t1 t2 =
111+ Stdlib. phys_equal t1 t2
112+ ||
113+ match t1, t2 with
114+ | Type i1 , Type i2 -> i1 = i2
115+ | _ -> false
116+
117+ let reftype_eq { nullable = n1 ; typ = t1 } { nullable = n2 ; typ = t2 } =
118+ Bool. (n1 = n2) && heaptype_eq t1 t2
119+
120+ let valtype_eq t1 t2 =
121+ Stdlib. phys_equal t1 t2
122+ ||
123+ match t1, t2 with
124+ | Ref t1 , Ref t2 -> reftype_eq t1 t2
125+ | _ -> false
126+
110127let rec output_uint ch i =
111128 if i < 128
112129 then output_byte ch i
@@ -489,23 +506,6 @@ module Read = struct
489506 (* We have large structs, that tend to hash to the same value *)
490507 Hashtbl. hash_param 15 100 t
491508
492- let heaptype_eq t1 t2 =
493- Stdlib. phys_equal t1 t2
494- ||
495- match t1, t2 with
496- | Type i1 , Type i2 -> i1 = i2
497- | _ -> false
498-
499- let reftype_eq { nullable = n1 ; typ = t1 } { nullable = n2 ; typ = t2 } =
500- Bool. (n1 = n2) && heaptype_eq t1 t2
501-
502- let valtype_eq t1 t2 =
503- Stdlib. phys_equal t1 t2
504- ||
505- match t1, t2 with
506- | Ref t1 , Ref t2 -> reftype_eq t1 t2
507- | _ -> false
508-
509509 let storagetype_eq t1 t2 =
510510 match t1, t2 with
511511 | Val v1 , Val v2 -> valtype_eq v1 v2
@@ -1583,11 +1583,11 @@ let check_export_import_types ~subtyping_info ~files i (desc : importdesc) i' im
15831583 match desc, import.desc with
15841584 | Func t , Func t' -> subtype subtyping_info t t'
15851585 | Table { limits; typ } , Table { limits = limits' ; typ = typ' } ->
1586- check_limits limits limits' && Poly. ( typ = typ')
1586+ check_limits limits limits' && reftype_eq typ typ'
15871587 | Mem limits , Mem limits' -> check_limits limits limits'
15881588 | Global { mut; typ } , Global { mut = mut' ; typ = typ' } ->
15891589 Bool. (mut = mut')
1590- && if mut then Poly. ( typ = typ') else val_subtype subtyping_info typ typ'
1590+ && if mut then valtype_eq typ typ' else val_subtype subtyping_info typ typ'
15911591 | Tag t , Tag t' -> t = t'
15921592 | _ -> false
15931593 in
0 commit comments