Skip to content

Commit fc4412c

Browse files
concrete_default -> concrete_legacy
1 parent 18a3816 commit fc4412c

File tree

8 files changed

+37
-35
lines changed

8 files changed

+37
-35
lines changed

ocaml/typing/ctype.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,8 @@ let type_sort ~why env ty =
22782278
| Ok _ -> Ok sort
22792279
| Error _ as e -> e
22802280

2281-
let type_non_null_sort ~why env ty =
2282-
let jkind, sort = Jkind.of_new_default_sort_var ~why in
2281+
let type_legacy_sort ~why env ty =
2282+
let jkind, sort = Jkind.of_new_legacy_sort_var ~why in
22832283
match constrain_type_jkind env ty jkind with
22842284
| Ok _ -> Ok sort
22852285
| Error _ as e -> e

ocaml/typing/ctype.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ val type_sort :
558558

559559
(* As [type_sort], but constrain the jkind to be non-null.
560560
Used for checking array elements. *)
561-
val type_non_null_sort :
562-
why:Jkind.History.concrete_default_creation_reason ->
561+
val type_legacy_sort :
562+
why:Jkind.History.concrete_legacy_creation_reason ->
563563
Env.t -> type_expr -> (Jkind.sort, Jkind.Violation.t) result
564564

565565
(* Jkind checking. [constrain_type_jkind] will update the jkind of type

ocaml/typing/jkind.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,11 +1131,11 @@ let of_new_sort_var ~why =
11311131

11321132
let of_new_sort ~why = fst (of_new_sort_var ~why)
11331133

1134-
let of_new_default_sort_var ~why =
1134+
let of_new_legacy_sort_var ~why =
11351135
let jkind, sort = Jkind_desc.of_new_sort_var Non_null in
1136-
fresh_jkind jkind ~why:(Concrete_default_creation why), sort
1136+
fresh_jkind jkind ~why:(Concrete_legacy_creation why), sort
11371137

1138-
let of_new_default_sort ~why = fst (of_new_default_sort_var ~why)
1138+
let of_new_legacy_sort ~why = fst (of_new_legacy_sort_var ~why)
11391139

11401140
(* CR layouts v2.8: remove this function *)
11411141
let of_const ~why
@@ -1392,8 +1392,8 @@ module Format_history = struct
13921392
([@@layout_poly] forces all variables of layout 'any' to be@ \
13931393
representable at call sites)"
13941394

1395-
let format_concrete_default_creation_reason ppf :
1396-
History.concrete_default_creation_reason -> unit = function
1395+
let format_concrete_legacy_creation_reason ppf :
1396+
History.concrete_legacy_creation_reason -> unit = function
13971397
| Unannotated_type_parameter path ->
13981398
fprintf ppf "it instantiates an unannotated type parameter of %a"
13991399
!printtyp_path path
@@ -1581,8 +1581,8 @@ module Format_history = struct
15811581
| Bits32_creation bits32 -> format_bits32_creation_reason ppf bits32
15821582
| Bits64_creation bits64 -> format_bits64_creation_reason ppf bits64
15831583
| Concrete_creation concrete -> format_concrete_creation_reason ppf concrete
1584-
| Concrete_default_creation concrete ->
1585-
format_concrete_default_creation_reason ppf concrete
1584+
| Concrete_legacy_creation concrete ->
1585+
format_concrete_legacy_creation_reason ppf concrete
15861586
| Imported ->
15871587
fprintf ppf "of %s requirements from an imported definition"
15881588
layout_or_kind
@@ -1617,7 +1617,7 @@ module Format_history = struct
16171617
| Creation reason -> (
16181618
fprintf ppf "@ because %a" (format_creation_reason ~layout_or_kind) reason;
16191619
match reason, jkind_desc with
1620-
| Concrete_default_creation _, Const _ ->
1620+
| Concrete_legacy_creation _, Const _ ->
16211621
fprintf ppf ",@ defaulted to %s %a" layout_or_kind Desc.format
16221622
jkind_desc
16231623
| _ -> ())
@@ -1798,7 +1798,7 @@ let score_reason = function
17981798
(* error_message annotated by the user should always take priority *)
17991799
| Creation (Annotated (With_error_message _, _)) -> 1
18001800
(* Concrete creation is quite vague, prefer more specific reasons *)
1801-
| Creation (Concrete_creation _ | Concrete_default_creation _) -> -1
1801+
| Creation (Concrete_creation _ | Concrete_legacy_creation _) -> -1
18021802
| _ -> 0
18031803

18041804
let combine_histories reason lhs rhs =
@@ -1885,8 +1885,8 @@ module Debug_printers = struct
18851885
| Optional_arg_default -> fprintf ppf "Optional_arg_default"
18861886
| Layout_poly_in_external -> fprintf ppf "Layout_poly_in_external"
18871887

1888-
let concrete_default_creation_reason ppf :
1889-
History.concrete_default_creation_reason -> unit = function
1888+
let concrete_legacy_creation_reason ppf :
1889+
History.concrete_legacy_creation_reason -> unit = function
18901890
| Unannotated_type_parameter path ->
18911891
fprintf ppf "Unannotated_type_parameter %a" !printtyp_path path
18921892
| Wildcard -> fprintf ppf "Wildcard"
@@ -2026,9 +2026,9 @@ module Debug_printers = struct
20262026
fprintf ppf "Bits64_creation %a" bits64_creation_reason bits64
20272027
| Concrete_creation concrete ->
20282028
fprintf ppf "Concrete_creation %a" concrete_creation_reason concrete
2029-
| Concrete_default_creation concrete ->
2030-
fprintf ppf "Concrete_default_creation %a"
2031-
concrete_default_creation_reason concrete
2029+
| Concrete_legacy_creation concrete ->
2030+
fprintf ppf "Concrete_legacy_creation %a" concrete_legacy_creation_reason
2031+
concrete
20322032
| Imported -> fprintf ppf "Imported"
20332033
| Imported_type_argument { parent_path; position; arity } ->
20342034
fprintf ppf "Imported_type_argument (pos %d, arity %d) of %a" position

ocaml/typing/jkind.mli

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,16 @@ val of_new_sort_var : why:History.concrete_creation_reason -> t * sort
311311
(** Create a fresh sort variable, packed into a jkind. *)
312312
val of_new_sort : why:History.concrete_creation_reason -> t
313313

314-
(** Same as [of_new_sort_var], but the jkind is lowered to [Non_null].
314+
(** Same as [of_new_sort_var], but the jkind is lowered to [Non_null]
315+
to mirror "legacy" OCaml values.
315316
Defaulting the sort variable produces exactly [value]. *)
316-
val of_new_default_sort_var :
317-
why:History.concrete_default_creation_reason -> t * sort
317+
val of_new_legacy_sort_var :
318+
why:History.concrete_legacy_creation_reason -> t * sort
318319

319-
(** Same as [of_new_sort], but the jkind is lowered to [Non_null].
320+
(** Same as [of_new_sort], but the jkind is lowered to [Non_null]
321+
to mirror "legacy" OCaml values.
320322
Defaulting the sort variable produces exactly [value]. *)
321-
val of_new_default_sort : why:History.concrete_default_creation_reason -> t
323+
val of_new_legacy_sort : why:History.concrete_legacy_creation_reason -> t
322324

323325
val of_const : why:History.creation_reason -> Const.t -> t
324326

ocaml/typing/jkind_intf.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ module History = struct
165165
| Optional_arg_default
166166
| Layout_poly_in_external
167167

168-
(* For sort variables that are in the "default" position
168+
(* For sort variables that are in the "legacy" position
169169
on the jkind lattice, defaulting exactly to [value]. *)
170170
(* CR layouts v3: after implementing separability, [Array_element]
171171
should instead accept representable separable jkinds. *)
172-
type concrete_default_creation_reason =
172+
type concrete_legacy_creation_reason =
173173
| Unannotated_type_parameter of Path.t
174174
| Wildcard
175175
| Unification_var
@@ -284,7 +284,7 @@ module History = struct
284284
| Bits32_creation of bits32_creation_reason
285285
| Bits64_creation of bits64_creation_reason
286286
| Concrete_creation of concrete_creation_reason
287-
| Concrete_default_creation of concrete_default_creation_reason
287+
| Concrete_legacy_creation of concrete_legacy_creation_reason
288288
| Imported
289289
| Imported_type_argument of
290290
{ parent_path : Path.t;

ocaml/typing/typecore.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ let solve_Ppat_array ~refine loc env mutability expected_ty =
16221622
if Types.is_mutable mutability then Predef.type_array
16231623
else Predef.type_iarray
16241624
in
1625-
let jkind, arg_sort = Jkind.of_new_default_sort_var ~why:Array_element in
1625+
let jkind, arg_sort = Jkind.of_new_legacy_sort_var ~why:Array_element in
16261626
let ty_elt = newgenvar jkind in
16271627
let expected_ty = generic_instance expected_ty in
16281628
unify_pat_types ~refine
@@ -8753,7 +8753,7 @@ and type_generic_array
87538753
in
87548754
check_construct_mutability ~loc ~env mutability argument_mode;
87558755
let argument_mode = mode_modality modalities argument_mode in
8756-
let jkind, elt_sort = Jkind.of_new_default_sort_var ~why:Array_element in
8756+
let jkind, elt_sort = Jkind.of_new_legacy_sort_var ~why:Array_element in
87578757
let ty = newgenvar jkind in
87588758
let to_unify = type_ ty in
87598759
with_explanation explanation (fun () ->

ocaml/typing/typeopt.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ let maybe_pointer_type env ty =
9999

100100
let maybe_pointer exp = maybe_pointer_type exp.exp_env exp.exp_type
101101

102-
(* CR layouts v2.8: Calling [type_non_null_sort] in [typeopt] is not ideal
102+
(* CR layouts v2.8: Calling [type_legacy_sort] in [typeopt] is not ideal
103103
and this function should be removed at some point. To do that, there
104104
needs to be a way to store sort vars on [Tconstr]s. That means
105105
either introducing a [Tpoly_constr], allow type parameters with
106106
sort info, or do something else. *)
107107
(* CR layouts v3.0: have a better error message
108108
for nullable jkinds.*)
109-
let type_non_null_sort ~why env loc ty =
110-
match Ctype.type_non_null_sort ~why env ty with
109+
let type_legacy_sort ~why env loc ty =
110+
match Ctype.type_legacy_sort ~why env ty with
111111
| Ok sort -> sort
112112
| Error err -> raise (Error (loc, Not_a_sort (ty, err)))
113113

@@ -174,7 +174,7 @@ let array_type_kind ~elt_sort env loc ty =
174174
match elt_sort with
175175
| Some s -> s
176176
| None ->
177-
type_non_null_sort ~why:Array_element env loc elt_ty
177+
type_legacy_sort ~why:Array_element env loc elt_ty
178178
in
179179
begin match classify env loc elt_ty elt_sort with
180180
| Any -> if Config.flat_float_array then Pgenarray else Paddrarray

ocaml/typing/typetexp.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ end = struct
435435
preserve backwards compatibility. But we also need [Any] callsites
436436
to accept nullable jkinds to allow cases like [type ('a : value_or_null) t = 'a]. *)
437437
| Any -> Jkind.Primitive.any ~why:(if is_named then Unification_var else Wildcard)
438-
| Sort -> Jkind.of_new_default_sort ~why:(if is_named then Unification_var else Wildcard)
438+
| Sort -> Jkind.of_new_legacy_sort ~why:(if is_named then Unification_var else Wildcard)
439439

440440
let new_any_var loc env jkind = function
441441
| { extensibility = Fixed } -> raise(Error(loc, env, No_type_wildcards))
@@ -541,7 +541,7 @@ let transl_type_param env path styp =
541541
to ask for it with an annotation. Some restriction here seems necessary
542542
for backwards compatibility (e.g., we wouldn't want [type 'a id = 'a] to
543543
have jkind any). But it might be possible to infer [any] in some cases. *)
544-
let jkind = Jkind.of_new_default_sort ~why:(Unannotated_type_parameter path) in
544+
let jkind = Jkind.of_new_legacy_sort ~why:(Unannotated_type_parameter path) in
545545
let attrs = styp.ptyp_attributes in
546546
match styp.ptyp_desc with
547547
Ptyp_any -> transl_type_param_var env loc attrs None jkind None
@@ -557,7 +557,7 @@ let transl_type_param env path styp =
557557

558558
let get_type_param_jkind path styp =
559559
match Jane_syntax.Core_type.of_ast styp with
560-
| None -> Jkind.of_new_default_sort ~why:(Unannotated_type_parameter path)
560+
| None -> Jkind.of_new_legacy_sort ~why:(Unannotated_type_parameter path)
561561
| Some (Jtyp_layout (Ltyp_var { name; jkind }), _attrs) ->
562562
let jkind, _ =
563563
Jkind.of_annotation

0 commit comments

Comments
 (0)