@@ -131,18 +131,25 @@ module Monomorph = struct
131131 in
132132 List. iter check m.tm_down_constraints;
133133 let kind =
134- if DynArray. length types > 0 then
135- CTypes (DynArray. to_list types)
136- else if not (PMap. is_empty ! fields) || ! is_open then
137- CStructural (! fields,! is_open)
134+ let k1 =
135+ if DynArray. length types > 0 then
136+ CTypes (DynArray. to_list types)
137+ else
138+ CUnknown
139+ in
140+ if not (PMap. is_empty ! fields) || ! is_open then
141+ let k2 = CStructural (! fields,! is_open) in
142+ match k1 with
143+ | CTypes _ -> CMixed [k1; k2]
144+ | _ -> k2
138145 else
139- CUnknown
146+ k1
140147 in
141148 ! monos,kind
142149
143150 let classify_down_constraints m = snd (classify_down_constraints' m)
144151
145- let check_down_constraints constr t =
152+ let rec check_down_constraints constr t =
146153 match constr with
147154 | CUnknown ->
148155 ()
@@ -156,6 +163,8 @@ module Monomorph = struct
156163 | CStructural (fields ,is_open ) ->
157164 let t2 = mk_anon ~fields (ref Closed ) in
158165 (! unify_ref) default_unification_context t t2
166+ | CMixed l ->
167+ List. iter (fun constr -> check_down_constraints constr t) l
159168
160169 let rec collect_up_constraints m =
161170 let rec collect m acc =
@@ -213,7 +222,7 @@ module Monomorph = struct
213222 (* Due to recursive constraints like in #9603, we tentatively bind the monomorph to the type we're checking
214223 against before checking the constraints. *)
215224 m.tm_type < - Some t;
216- let monos, kind = classify_down_constraints' m in
225+ let kind = classify_down_constraints m in
217226 Std. finally (fun () -> m.tm_type < - None ) (fun () -> check_down_constraints kind t) () ;
218227 do_bind m t
219228 end
@@ -227,7 +236,7 @@ module Monomorph = struct
227236 | CTypes [(t,_)] ->
228237 do_bind m t;
229238 ()
230- | CTypes _ ->
239+ | CTypes _ | CMixed _ ->
231240 ()
232241 | CStructural (fields ,_ ) ->
233242 let check_recursion cf =
0 commit comments