@@ -24,13 +24,31 @@ open Typedtree
2424
2525exception Dont_match
2626
27+ (* When comparing externals in signatures, re-derive arity/from_constructor from
28+ the value's type so abstract aliases (e.g. opaque function types) don't keep
29+ default zeros stored in the primitive descriptor, which would make equal
30+ externals look different. *)
31+ let normalize_primitive ~env val_type (prim : Primitive.description ) =
32+ match Ctype. get_arity env val_type with
33+ | Some prim_arity ->
34+ let prim_from_constructor =
35+ match (Ctype. repr val_type).desc with
36+ | Tconstr _ -> true
37+ | _ -> prim.prim_from_constructor
38+ in
39+ Primitive. with_arity prim ~arity: prim_arity
40+ ~from_constructor: prim_from_constructor
41+ | None -> prim
42+
2743let value_descriptions ~loc env name (vd1 : Types.value_description )
2844 (vd2 : Types.value_description ) =
2945 Builtin_attributes. check_deprecated_inclusion ~def: vd1.val_loc
3046 ~use: vd2.val_loc loc vd1.val_attributes vd2.val_attributes (Ident. name name);
3147 if Ctype. moregeneral env true vd1.val_type vd2.val_type then
3248 match (vd1.val_kind, vd2.val_kind) with
3349 | Val_prim p1 , Val_prim p2 ->
50+ let p1 = normalize_primitive ~env vd1.val_type p1 in
51+ let p2 = normalize_primitive ~env vd2.val_type p2 in
3452 if ! Primitive. coerce p1 p2 then Tcoerce_none else raise Dont_match
3553 | Val_prim p , _ ->
3654 let pc =
0 commit comments