Skip to content

Commit 815a93a

Browse files
goldfireregretay-js
authored andcommitted
Fix bug around persisting unsafe_mode_crossing (oxcaml#3812)
* Commit test (it fails; trust me) * Fix the bug
1 parent c15a772 commit 815a93a

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(* TEST
2+
readonly_files = "unsafe_across_files.mli unsafe_across_files.ml";
3+
setup-ocamlc.byte-build-env;
4+
module = "unsafe_across_files.mli";
5+
ocamlc.byte;
6+
module = "unsafe_across_files.ml";
7+
ocamlc.byte;
8+
*)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type ('a, 'witness) t : immutable_data with 'witness = { compare : 'a -> 'a -> int }
2+
[@@unsafe_allow_any_mode_crossing]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type ('a, 'witness) t : immutable_data with 'witness = { compare : 'a -> 'a -> int }
2+
[@@unsafe_allow_any_mode_crossing]

typing/subst.ml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,20 +559,35 @@ let constructor_declaration copy_scope s c =
559559
cd_uid = c.cd_uid;
560560
}
561561

562+
let unsafe_mode_crossing copy_scope s loc
563+
{ unsafe_mod_bounds; unsafe_with_bounds } =
564+
{ unsafe_mod_bounds;
565+
unsafe_with_bounds =
566+
Jkind.With_bounds.map_type_expr (typexp copy_scope s loc)
567+
unsafe_with_bounds }
568+
562569
let rec type_declaration' copy_scope s decl =
570+
let unsafe_mode_crossing =
571+
Option.map (unsafe_mode_crossing copy_scope s decl.type_loc)
572+
in
563573
{ type_params = List.map (typexp copy_scope s decl.type_loc) decl.type_params;
564574
type_arity = decl.type_arity;
565575
type_kind =
566576
begin match decl.type_kind with
567577
Type_abstract r -> Type_abstract r
568578
| Type_variant (cstrs, rep, umc) ->
569579
Type_variant (List.map (constructor_declaration copy_scope s) cstrs,
570-
rep, umc)
580+
rep,
581+
unsafe_mode_crossing umc)
571582
| Type_record(lbls, rep, umc) ->
572-
Type_record (List.map (label_declaration copy_scope s) lbls, rep, umc)
583+
Type_record (List.map (label_declaration copy_scope s) lbls,
584+
rep,
585+
unsafe_mode_crossing umc)
573586
| Type_record_unboxed_product(lbls, rep, umc) ->
574587
Type_record_unboxed_product
575-
(List.map (label_declaration copy_scope s) lbls, rep, umc)
588+
(List.map (label_declaration copy_scope s) lbls,
589+
rep,
590+
unsafe_mode_crossing umc)
576591
| Type_open -> Type_open
577592
end;
578593
type_manifest =

0 commit comments

Comments
 (0)