@@ -191,37 +191,37 @@ let value_descriptions ~loc env name
191
191
| Val_prim p1 -> begin
192
192
match vd2.val_kind with
193
193
| Val_prim p2 -> begin
194
- let ty1_global, _, _ = Ctype. instance_prim p1 vd1.val_type in
195
- let ty2_global =
196
- let ty2, mode2, _ = Ctype. instance_prim p2 vd2.val_type in
197
- Option. iter
198
- ( fun m -> Mode.Locality. submode_exn m Mode.Locality. global)
199
- mode2 ;
200
- ty2
201
- in
202
- ( try Ctype. moregeneral env true ty1_global ty2_global
203
- with Ctype. Moregen err -> raise ( Dont_match ( Type err)));
204
- let ty1_local , _, _ = Ctype. instance_prim p1 vd1.val_type in
205
- let ty2_local =
206
- let ty2, mode2, _ = Ctype. instance_prim p2 vd2.val_type in
207
- Option. iter
208
- ( fun m -> Mode.Locality. submode_exn Mode.Locality. local m)
209
- mode2;
210
- ty2
211
- in
212
- ( try Ctype. moregeneral env true ty1_local ty2_local
213
- with Ctype. Moregen err -> raise ( Dont_match ( Type err))) ;
194
+ let restrict_locality = [
195
+ ( fun m -> Mode.Locality. submode_exn m Mode.Locality. global);
196
+ ( fun m -> Mode.Locality. submode_exn Mode.Locality. local m)
197
+ ] in
198
+ let restrict_yielding = [
199
+ ( fun m -> Mode.Yielding. submode_exn m Mode.Yielding. unyielding) ;
200
+ ( fun m -> Mode.Yielding. submode_exn Mode.Yielding. yielding m)
201
+ ] in
202
+ List. iter ( fun restrict_loc ->
203
+ List. iter ( fun restrict_yield ->
204
+ let ty1, _ , _, _ = Ctype. instance_prim p1 vd1.val_type in
205
+ let ty2, mode_l2, mode_y2, _ = Ctype. instance_prim p2 vd2.val_type in
206
+ Option. iter restrict_loc mode_l2;
207
+ Option. iter restrict_yield mode_y2;
208
+ try
209
+ Ctype. moregeneral env true ty1 ty2
210
+ with Ctype. Moregen err ->
211
+ raise ( Dont_match ( Type err))
212
+ ) restrict_yielding
213
+ ) restrict_locality ;
214
214
match primitive_descriptions p1 p2 with
215
215
| None -> Tcoerce_none
216
216
| Some err -> raise (Dont_match (Primitive_mismatch err))
217
217
end
218
218
| _ ->
219
- let ty1, mode1 , sort1 = Ctype. instance_prim p1 vd1.val_type in
219
+ let ty1, mode_l1, _ , sort1 = Ctype. instance_prim p1 vd1.val_type in
220
220
(try Ctype. moregeneral env true ty1 vd2.val_type
221
221
with Ctype. Moregen err -> raise (Dont_match (Type err)));
222
222
let pc =
223
223
{pc_desc = p1; pc_type = vd2.Types. val_type;
224
- pc_poly_mode = Option. map Mode.Locality. disallow_right mode1 ;
224
+ pc_poly_mode = Option. map Mode.Locality. disallow_right mode_l1 ;
225
225
pc_poly_sort= sort1;
226
226
pc_env = env; pc_loc = vd1.Types. val_loc; } in
227
227
Tcoerce_primitive pc
0 commit comments