@@ -136,7 +136,7 @@ type type_mismatch =
136
136
| Field_arity of Ident .t
137
137
| Field_names of int * string * string
138
138
| Field_missing of bool * Ident .t
139
- | Record_representation of bool (* true means second one is unboxed float *)
139
+ | Record_representation of record_representation * record_representation
140
140
| Unboxed_representation of bool (* true means second one is unboxed *)
141
141
| Immediate
142
142
@@ -161,10 +161,25 @@ let report_type_mismatch0 first second decl ppf err =
161
161
| Field_missing (b , s ) ->
162
162
pr " The field %s is only present in %s %s"
163
163
(Ident. name s) (if b then second else first) decl
164
- | Record_representation b ->
165
- pr " Their internal representations differ:@ %s %s %s"
166
- (if b then second else first) decl
167
- " uses @@obj representation"
164
+ | Record_representation (rep1 , rep2 ) ->
165
+ let default () = pr " Their internal representations differ" in
166
+ ( match rep1, rep2 with
167
+ | Record_optional_labels lbls1 , Record_optional_labels lbls2 ->
168
+ let onlyInLhs =
169
+ Ext_list. find_first lbls1 (fun l -> not (Ext_list. mem_string lbls2 l)) in
170
+ let onlyInRhs =
171
+ Ext_list. find_first lbls2 (fun l -> not (Ext_list. mem_string lbls1 l)) in
172
+ (match onlyInLhs, onlyInRhs with
173
+ | Some l , _ ->
174
+ pr " @optional label %s only in %s" l second
175
+ | _ , Some l ->
176
+ pr " @optional label %s only in %s" l first
177
+ | None , None -> default () )
178
+ | _ ->
179
+ default ()
180
+ )
181
+ (* pr "Their internal representations differ:@ rep1:%s rep2:%s decl:%s"
182
+ first second decl *)
168
183
| Unboxed_representation b ->
169
184
pr " Their internal representations differ:@ %s %s %s"
170
185
(if b then second else first) decl
@@ -314,7 +329,7 @@ let type_declarations ?(equality = false) ~loc env name decl1 id decl2 =
314
329
let err = compare_records ~loc env decl1.type_params decl2.type_params
315
330
1 labels1 labels2 in
316
331
if err <> [] || rep1 = rep2 then err else
317
- [Record_representation (rep2 = Record_object )]
332
+ [Record_representation (rep1, rep2 )]
318
333
| (Type_open, Type_open) -> []
319
334
| (_ , _ ) -> [Kind ]
320
335
in
0 commit comments