@@ -161,19 +161,40 @@ let heap_type_sub (ty : W.heap_type) (ty' : W.heap_type) st =
161161 match ty, ty' with
162162 | Func , Func
163163 | Extern , Extern
164- | (Any | Eq | I31 | Type _), Any
165- | (Eq | I31 | Type _), Eq
166- | I31 , I31 -> true , st
164+ | (Any | Eq | Struct | Array | I31 | None_ | Type _), Any
165+ | (Eq | Struct | Array | I31 | None_ | Type _), Eq
166+ | (None_ | Struct ), Struct -> true , st
167+ | (None_ | Array ), Array -> true , st
168+ | (None_ | I31 ), I31 -> true , st
169+ | None_ , None_ -> true , st
170+ | Type t , Struct ->
171+ ( (let type_field = Hashtbl. find st.context.types t in
172+ match type_field.typ with
173+ | Struct _ -> true
174+ | Array _ | Func _ -> false )
175+ , st )
176+ | Type t , Array ->
177+ ( (let type_field = Hashtbl. find st.context.types t in
178+ match type_field.typ with
179+ | Array _ -> true
180+ | Struct _ | Func _ -> false )
181+ , st )
167182 | Type t , Type t' -> type_index_sub t t' st
183+ | None_ , Type t ->
184+ ( (let type_field = Hashtbl. find st.context.types t in
185+ match type_field.typ with
186+ | Struct _ | Array _ -> true
187+ | Func _ -> false )
188+ , st )
168189 (* Func and Extern are only in suptyping relation with themselves *)
169190 | Func , _
170191 | _, Func
171192 | Extern , _
172193 | _, Extern
173194 (* Any has no supertype *)
174195 | Any , _
175- (* I31, struct and arrays have no subtype (of a different kind) *)
176- | _ , (I31 | Type _ ) -> false , st
196+ (* I31, struct, array and none have no other subtype *)
197+ | _ , (I31 | Type _ | Struct | Array | None_ ) -> false , st
177198
178199let register_global name ?exported_name ?(constant = false ) typ init st =
179200 st.context.other_fields < -
0 commit comments