Skip to content

Commit 41f213b

Browse files
authored
Updates for 5.2.0minus-9 (#137)
* Import ocaml sources for oxcaml/oxcaml@c3c58afb390 * Commit conflicts * Resolve conflicts * Fix type errors * Bump version numbers * Update ignored flags * Promote tests * Format
1 parent 8a8eaee commit 41f213b

File tree

106 files changed

+46153
-43299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+46153
-43299
lines changed

src/analysis/destruct.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,9 @@ let refine_and_generate_branches patt config source patterns sub_patterns =
773773
(top_patt.Typedtree.pat_loc, str)
774774

775775
let refine_complete_match (type a) parents (patt : a Typedtree.general_pattern)
776-
config source patterns =
776+
config source
777+
(patterns :
778+
Typedtree.value Typedtree.pattern_desc Typedtree.pattern_data list) =
777779
match Typedtree.classify_pattern patt with
778780
| Computation -> raise (Not_allowed "computation pattern")
779781
| Value ->

src/analysis/env_lookup.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ let by_longident (nss : Namespace.inferred list) ident env =
141141
Namespace.packed_label_description =
142142
(* Try looking up in boxed namespace, and then fallback to unboxed if that
143143
fails *)
144-
try P (Env.find_label_by_name Legacy ident env)
144+
try
145+
(P (Env.find_label_by_name Legacy ident env)
146+
: Namespace.packed_label_description)
145147
with Not_found ->
146148
P (Env.find_label_by_name Unboxed_product ident env)
147149
in

src/kernel/mconfig.ml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -435,30 +435,21 @@ let ocaml_ignored_flags =
435435
"-compat-32";
436436
"-config";
437437
"-custom";
438-
"-dalloc";
439438
"-dclambda";
440439
"-dcmm";
441-
"-dcombine";
442440
"-dcse";
443441
"-dflambda";
444442
"-dflambda-no-invariants";
445443
"-dflambda-verbose";
446444
"-dinstr";
447-
"-dinterf";
448445
"-dlambda";
449446
"-dlinear";
450-
"-dlive";
451447
"-dparsetree";
452-
"-dprefer";
453448
"-dshape";
454449
"-drawclambda";
455450
"-drawflambda";
456451
"-drawlambda";
457-
"-dreload";
458-
"-dsel";
459452
"-dsource";
460-
"-dspill";
461-
"-dsplit";
462453
"-dstartup";
463454
"-dtimings";
464455
"-dprofile";
@@ -535,6 +526,7 @@ let ocaml_ignored_flags =
535526
"-flambda2-speculative-inlining-only-if-arguments-useful";
536527
"-flambda2-unbox-along-intra-function-control-flow";
537528
"-flambda2-unicode";
529+
"-flambda2-kind-checks";
538530
"-no-flambda2-backend-cse-at-toplevel";
539531
"-no-flambda2-debug";
540532
"-no-flambda2-debug-concrete-types-only-on-canonicals";
@@ -569,8 +561,6 @@ let ocaml_ignored_flags =
569561
"-ddebug-invariants";
570562
"-cfg-peephole-optimize";
571563
"-no-cfg-peephole-optimize";
572-
"-cfg-cse-optimize";
573-
"-no-cfg-cse-optimize";
574564
"-verbose-types";
575565
"-no-verbose-types";
576566
"-fsse3";
@@ -609,15 +599,11 @@ let ocaml_ignored_flags =
609599
"-gno-upstream-dwarf";
610600
"-dzero-alloc";
611601
"-dletreclambda";
612-
"-cfg-zero-alloc-checker";
613-
"-no-cfg-zero-alloc-checker";
614602
"-dcounters";
615603
"-vectorize";
616604
"-no-vectorize";
617605
"-dvectorize";
618606
"-dump-into-csv";
619-
"-cfg-selection";
620-
"-no-cfg-selection";
621607
"-no-mach-ir";
622608
"-flambda2-reaper";
623609
"-no-flambda2-reaper";

src/ocaml/parsing/ast_helper.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module Pat:
126126
-> (string option * pattern) list -> closed_flag
127127
-> pattern
128128
val construct: ?loc:loc -> ?attrs:attrs ->
129-
lid -> (str list * pattern) option -> pattern
129+
lid -> ((str * jkind_annotation option) list * pattern) option -> pattern
130130
val variant: ?loc:loc -> ?attrs:attrs -> label -> pattern option -> pattern
131131
val record: ?loc:loc -> ?attrs:attrs -> (lid * pattern) list -> closed_flag
132132
-> pattern

src/ocaml/parsing/ast_iterator.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,12 @@ module P = struct
569569
iter_loc sub l;
570570
iter_opt
571571
(fun (vl,p) ->
572-
List.iter (iter_loc sub) vl;
573-
sub.pat sub p)
572+
List.iter
573+
(fun (v,j) ->
574+
iter_loc sub v;
575+
iter_opt (sub.jkind_annotation sub) j)
576+
vl;
577+
sub.pat sub p)
574578
p
575579
| Ppat_variant (_l, p) -> iter_opt (sub.pat sub) p
576580
| Ppat_record (lpl, _cf)

src/ocaml/parsing/ast_mapper.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,12 @@ module P = struct
649649
| Ppat_construct (l, p) ->
650650
construct ~loc ~attrs (map_loc sub l)
651651
(map_opt
652-
(fun (vl, p) -> List.map (map_loc sub) vl, sub.pat sub p)
652+
(fun (vl, p) ->
653+
List.map
654+
(fun (v, jk) ->
655+
map_loc sub v, Option.map (sub.jkind_annotation sub) jk)
656+
vl,
657+
sub.pat sub p)
653658
p)
654659
| Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p)
655660
| Ppat_record (lpl, cf) ->

src/ocaml/parsing/parsetree.mli

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,17 @@ and pattern_desc =
290290
- If Closed, [n >= 2]
291291
- If Open, [n >= 1]
292292
*)
293-
| Ppat_construct of Longident.t loc * (string loc list * pattern) option
293+
| Ppat_construct of
294+
Longident.t loc
295+
* ((string loc * jkind_annotation option) list * pattern) option
294296
(** [Ppat_construct(C, args)] represents:
295297
- [C] when [args] is [None],
296298
- [C P] when [args] is [Some ([], P)]
297299
- [C (P1, ..., Pn)] when [args] is
298300
[Some ([], Ppat_tuple [P1; ...; Pn])]
299-
- [C (type a b) P] when [args] is [Some ([a; b], P)]
301+
- [C (type a b) P] when [args] is [Some ([a, None; b, None], P)]
302+
- [C (type (a : k) b) P]
303+
when [args] is [Some ([a, Some k; b, None], P)]
300304
*)
301305
| Ppat_variant of label * pattern option
302306
(** [Ppat_variant(`A, pat)] represents:

src/ocaml/parsing/pprintast.ml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ let ident_of_name ppf txt =
105105
else "(%s)"
106106
in fprintf ppf format txt
107107

108-
let ident_of_name_loc ppf s = ident_of_name ppf s.txt
109-
110108
let protect_longident ppf print_longident longprefix txt =
111109
if not (needs_parens txt) then
112110
fprintf ppf "%a.%a" print_longident longprefix ident_of_name txt
@@ -432,11 +430,11 @@ let include_kind f = function
432430
| Structure -> ()
433431
434432
(* c ['a,'b] *)
435-
let rec class_params_def ctxt f = function
433+
let rec class_params_def f = function
436434
| [] -> ()
437435
| l ->
438436
pp f "[%a] " (* space *)
439-
(list (type_param ctxt) ~sep:",") l
437+
(list type_param ~sep:",") l
440438
441439
and type_with_label ctxt f (label, c, mode) =
442440
match label with
@@ -499,6 +497,8 @@ and name_jkind f (name, jkind) =
499497
ident_of_name name
500498
(jkind_annotation reset_ctxt) jkind
501499
500+
and name_loc_jkind f (str, jkind) = name_jkind f (str.txt,jkind)
501+
502502
and core_type ctxt f x =
503503
let filtered_attrs = filter_curry_attrs x.ptyp_attributes in
504504
if filtered_attrs <> [] then begin
@@ -686,7 +686,7 @@ and pattern1 ctxt (f:Format.formatter) (x:pattern) : unit =
686686
pp f "%a@;%a" longident_loc li (simple_pattern ctxt) x
687687
| Some (vl, x) ->
688688
pp f "%a@ (type %a)@;%a" longident_loc li
689-
(list ~sep:"@ " ident_of_name_loc) vl
689+
(list ~sep:"@ " name_loc_jkind) vl
690690
(simple_pattern ctxt) x
691691
| None -> pp f "%a" longident_loc li)
692692
| _ -> simple_pattern ctxt f x
@@ -1290,7 +1290,7 @@ and class_type_declaration_list ctxt f l =
12901290
let { pci_params=ls; pci_name={ txt; _ }; _ } = x in
12911291
pp f "@[<2>%s %a%a%a@ =@ %a@]%a" kwd
12921292
virtual_flag x.pci_virt
1293-
(class_params_def ctxt) ls
1293+
class_params_def ls
12941294
ident_of_name txt
12951295
(class_type ctxt) x.pci_expr
12961296
(item_attributes ctxt) x.pci_attributes
@@ -1465,15 +1465,15 @@ and module_type ctxt f x =
14651465
and with_constraint ctxt f = function
14661466
| Pwith_type (li, ({ptype_params= ls ;_} as td)) ->
14671467
pp f "type@ %a %a =@ %a"
1468-
(type_params ctxt) ls
1468+
type_params ls
14691469
longident_loc li (type_declaration ctxt) td
14701470
| Pwith_module (li, li2) ->
14711471
pp f "module %a =@ %a" longident_loc li longident_loc li2;
14721472
| Pwith_modtype (li, mty) ->
14731473
pp f "module type %a =@ %a" longident_loc li (module_type ctxt) mty;
14741474
| Pwith_typesubst (li, ({ptype_params=ls;_} as td)) ->
14751475
pp f "type@ %a %a :=@ %a"
1476-
(type_params ctxt) ls
1476+
type_params ls
14771477
longident_loc li
14781478
(type_declaration ctxt) td
14791479
| Pwith_modsubst (li, li2) ->
@@ -1528,7 +1528,7 @@ and signature_item ctxt f x : unit =
15281528
let class_description kwd f ({pci_params=ls;pci_name={txt;_};_} as x) =
15291529
pp f "@[<2>%s %a%a%a@;:@;%a@]%a" kwd
15301530
virtual_flag x.pci_virt
1531-
(class_params_def ctxt) ls
1531+
class_params_def ls
15321532
ident_of_name txt
15331533
(class_type ctxt) x.pci_expr
15341534
(item_attributes ctxt) x.pci_attributes
@@ -1893,7 +1893,7 @@ and structure_item ctxt f x =
18931893
let args, constr, cl = extract_class_args x.pci_expr in
18941894
pp f "@[<2>%s %a%a%a %a%a=@;%a@]%a" kwd
18951895
virtual_flag x.pci_virt
1896-
(class_params_def ctxt) ls
1896+
class_params_def ls
18971897
ident_of_name txt
18981898
(list (label_exp ctxt) ~last:"@ ") args
18991899
(option class_constraint) constr
@@ -1968,12 +1968,26 @@ and structure_item ctxt f x =
19681968
| Pstr_kind_abbrev (name, jkind) ->
19691969
kind_abbrev ctxt f name jkind
19701970
1971-
and type_param ctxt f (ct, (a,b)) =
1972-
pp f "%s%s%a" (type_variance a) (type_injectivity b) (core_type ctxt) ct
1971+
(* Don't just use [core_type] because we do not want parens around params
1972+
with jkind annotations *)
1973+
and core_type_param f ct = match ct.ptyp_desc with
1974+
| Ptyp_any None -> pp f "_"
1975+
| Ptyp_any (Some jk) -> pp f "_ : %a" (jkind_annotation reset_ctxt) jk
1976+
| Ptyp_var (s, None) -> tyvar f s
1977+
| Ptyp_var (s, Some jk) ->
1978+
pp f "%a : %a" tyvar s (jkind_annotation reset_ctxt) jk
1979+
| _ -> Misc.fatal_error "unexpected type in core_type_param"
19731980
1974-
and type_params ctxt f = function
1981+
and type_param f (ct, (a,b)) =
1982+
pp f "%s%s%a" (type_variance a) (type_injectivity b) core_type_param ct
1983+
1984+
and type_params f = function
19751985
| [] -> ()
1976-
| l -> pp f "%a " (list (type_param ctxt) ~first:"(" ~last:")" ~sep:",@;") l
1986+
(* Normally, one param doesn't get parentheses, but it does when there is
1987+
a jkind annotation. *)
1988+
| [{ ptyp_desc = Ptyp_any (Some _) | Ptyp_var (_, Some _) }, _ as param] ->
1989+
pp f "(%a) " type_param param
1990+
| l -> pp f "%a " (list type_param ~first:"(" ~last:")" ~sep:",@;") l
19771991
19781992
and type_def_list ctxt f (rf, exported, l) =
19791993
let type_decl kwd rf f x =
@@ -1991,7 +2005,7 @@ and type_def_list ctxt f (rf, exported, l) =
19912005
in
19922006
pp f "@[<2>%s %a%a%a%t%s%a@]%a" kwd
19932007
nonrec_flag rf
1994-
(type_params ctxt) x.ptype_params
2008+
type_params x.ptype_params
19952009
ident_of_name x.ptype_name.txt
19962010
layout_annot eq
19972011
(type_declaration ctxt) x
@@ -2074,11 +2088,7 @@ and type_extension ctxt f x =
20742088
pp f "@\n|@;%a" (extension_constructor ctxt) x
20752089
in
20762090
pp f "@[<2>type %a%a += %a@ %a@]%a"
2077-
(fun f -> function
2078-
| [] -> ()
2079-
| l ->
2080-
pp f "%a@;" (list (type_param ctxt) ~first:"(" ~last:")" ~sep:",") l)
2081-
x.ptyext_params
2091+
type_params x.ptyext_params
20822092
longident_loc x.ptyext_path
20832093
private_flag x.ptyext_private (* Cf: #7200 *)
20842094
(list ~sep:"" extension_constructor)

src/ocaml/parsing/printast.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ and pattern i ppf x =
258258
line i ppf "Ppat_construct %a\n" fmt_longident_loc li;
259259
option i
260260
(fun i ppf (vl, p) ->
261-
list i string_loc ppf vl;
261+
list i
262+
(fun i ppf (v, jk) ->
263+
string_loc i ppf v;
264+
jkind_annotation_opt i ppf jk)
265+
ppf vl;
262266
pattern i ppf p)
263267
ppf po
264268
| Ppat_variant (l, po) ->

0 commit comments

Comments
 (0)