Skip to content

Commit 3cab6af

Browse files
authored
Merge pull request #201 from oxcaml/merge-5.2.0minus-24
Merge 5.2.0minus-24
2 parents 1f482cc + 1927fee commit 3cab6af

File tree

144 files changed

+24258
-23014
lines changed

Some content is hidden

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

144 files changed

+24258
-23014
lines changed

src/analysis/completion.ml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ let { Logger.log } = Logger.for_section "Completion"
3737

3838
type raw_info =
3939
[ `Constructor of Types.constructor_description
40-
| `Modtype of Types.module_type
41-
| `Modtype_declaration of Ident.t * Types.modtype_declaration
40+
| `Modtype of Subst.Lazy.module_type
41+
| `Modtype_declaration of Ident.t * Subst.Lazy.modtype_declaration
4242
| `None
4343
| `String of string
4444
| `Type_declaration of Ident.t * Types.type_declaration
@@ -47,8 +47,11 @@ type raw_info =
4747

4848
let raw_info_printer : raw_info -> _ = function
4949
| `Constructor c -> `Print (Out_type (Browse_misc.print_constructor c))
50-
| `Modtype mt -> `Print (Out_module_type (Printtyp.tree_of_modtype mt))
50+
| `Modtype mt ->
51+
let mt = Subst.Lazy.force_modtype mt in
52+
`Print (Out_module_type (Printtyp.tree_of_modtype mt))
5153
| `Modtype_declaration (id, mtd) ->
54+
let mtd = Subst.Lazy.force_modtype_decl mtd in
5255
`Print (Out_sig_item (Printtyp.tree_of_modtype_declaration id mtd))
5356
| `None -> `String ""
5457
| `String s -> `String s
@@ -315,8 +318,8 @@ let get_candidates ?get_doc ?target_type ?prefix_path ~prefix kind ~validate env
315318
let val_attributes v = v.Subst.Lazy.val_attributes in
316319
let type_attributes t = t.Types.type_attributes in
317320
let lbl_attributes l = l.Types.lbl_attributes in
318-
let mtd_attributes t = t.Types.mtd_attributes in
319-
let md_attributes t = t.Types.md_attributes in
321+
let mtd_attributes t = t.Subst.Lazy.mtd_attributes in
322+
let md_attributes t = t.Subst.Lazy.md_attributes in
320323
let make_candidate ~attrs ~exact name ?loc ?path ty =
321324
make_candidate ~get_doc ~prefix_path ~attrs ~exact name ?loc ?path ty
322325
in
@@ -459,18 +462,18 @@ let get_candidates ?get_doc ?target_type ?prefix_path ~prefix kind ~validate env
459462
:: candidates)
460463
prefix_path env []
461464
| `Modules ->
462-
Env.fold_modules
465+
Env.fold_modules_lazy
463466
(fun name path v candidates ->
464467
let attrs = md_attributes v in
465-
let v = v.Types.md_type in
468+
let v = v.Subst.Lazy.md_type in
466469
if not @@ validate `Uident `Mod name then candidates
467470
else
468471
make_weighted_candidate ~exact:(name = prefix) name ~path (`Mod v)
469472
~attrs
470473
:: candidates)
471474
prefix_path env []
472475
| `Modules_type ->
473-
Env.fold_modtypes
476+
Env.fold_modtypes_lazy
474477
(fun name path v candidates ->
475478
if not @@ validate `Uident `Mod name then candidates
476479
else
@@ -683,8 +686,8 @@ let complete_prefix ?get_doc ?target_type ?(kinds = []) ~keywords ~prefix
683686
with Not_found -> []
684687

685688
(* Propose completion from a particular node *)
686-
let branch_complete buffer ?get_doc ?target_type ?kinds ~keywords prefix =
687-
function
689+
let branch_complete buffer ?get_doc ?target_type ?kinds ~keywords prefix :
690+
_ -> raw_info raw_entry list = function
688691
| [] -> []
689692
| (env, node) :: branch -> (
690693
match node with

src/analysis/completion.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ open Query_protocol
3232

3333
type raw_info =
3434
[ `Constructor of Types.constructor_description
35-
| `Modtype of Types.module_type
36-
| `Modtype_declaration of Ident.t * Types.modtype_declaration
35+
| `Modtype of Subst.Lazy.module_type
36+
| `Modtype_declaration of Ident.t * Subst.Lazy.modtype_declaration
3737
| `None
3838
| `String of string
3939
| `Type_declaration of Ident.t * Types.type_declaration

src/analysis/env_lookup.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ let by_longident (nss : Namespace.inferred list) ident env =
113113
raise (Found (path, Constructor, cd.cstr_uid, loc))
114114
| `Mod ->
115115
log ~title:"lookup" "lookup in module namespace";
116-
let path, md = Env.find_module_by_name ident env in
117-
raise (Found (path, Module, md.md_uid, md.Types.md_loc))
116+
let path, md = Env.find_module_by_name_lazy ident env in
117+
raise (Found (path, Module, md.md_uid, md.md_loc))
118118
| `Modtype ->
119119
log ~title:"lookup" "lookup in module type namespace";
120-
let path, mtd = Env.find_modtype_by_name ident env in
121-
raise (Found (path, Module_type, mtd.mtd_uid, mtd.Types.mtd_loc))
120+
let path, mtd = Env.find_modtype_by_name_lazy ident env in
121+
raise (Found (path, Module_type, mtd.mtd_uid, mtd.mtd_loc))
122122
| `Type ->
123123
log ~title:"lookup" "lookup in type namespace";
124124
let path, typ_decl = Env.find_type_by_name ident env in

src/analysis/locate.ml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ module Preferences : sig
348348
val src : string -> File.t
349349
val build : string -> File.t
350350

351-
val is_preferred : string -> bool
351+
val is_preferred_source : string -> bool
352+
val is_preferred_build_or_source : string -> bool
352353
end = struct
353354
let prioritize_impl = ref true
354355

@@ -361,11 +362,17 @@ end = struct
361362
let src file = if !prioritize_impl then File.ml file else File.mli file
362363
let build file = if !prioritize_impl then File.cms file else File.cmsi file
363364

364-
let is_preferred fn =
365+
let is_preferred_source fn =
365366
match File.of_filename fn with
366367
| Some (ML _) -> !prioritize_impl
367368
| Some (MLI _) -> not !prioritize_impl
368369
| _ -> false
370+
371+
let is_preferred_build_or_source fn =
372+
match File.of_filename fn with
373+
| Some (ML _ | CMS _ | CMT _) -> !prioritize_impl
374+
| Some (MLI _ | CMSI _ | CMTI _) -> not !prioritize_impl
375+
| Some (MLL _) | None -> false
369376
end
370377

371378
module File_switching : sig
@@ -469,10 +476,30 @@ module Utils = struct
469476
try Some (Misc.find_in_path_normalized ?fallback path fname)
470477
with Not_found -> None
471478
in
472-
match try_one file with
473-
| Some _ as f -> f
474-
| None -> Option.bind ~f:try_one (File.to_legacy file)
479+
(* Prefer files first by whether they're preferred and then by their legacy-ness.
480+
(legacy = cmt/cmti, nonlegacy = cms/cmsi). Be as lazy as possible about finding
481+
files, since this may involve looking through a lot of directories. *)
482+
let rec find_first_preferred ~first_found_file files_to_try =
483+
match files_to_try with
484+
| file_to_try :: rest_files_to_try -> (
485+
match try_one file_to_try with
486+
| Some found_file as found_file_opt ->
487+
if Preferences.is_preferred_build_or_source found_file then
488+
found_file_opt
489+
else
490+
let first_found_file =
491+
match first_found_file with
492+
| Some _ as first_found_file -> first_found_file
493+
| None -> found_file_opt
494+
in
495+
find_first_preferred ~first_found_file rest_files_to_try
496+
| None -> find_first_preferred ~first_found_file rest_files_to_try)
497+
| [] -> first_found_file
498+
in
499+
find_first_preferred ~first_found_file:None
500+
([ Some file; File.to_legacy file ] |> List.filter_map ~f:(fun x -> x))
475501
in
502+
476503
try
477504
Some (List.find_map Mconfig.(config.merlin.suffixes) ~f:attempt_search)
478505
with Not_found -> None
@@ -653,7 +680,7 @@ let find_source ~config loc =
653680
let path' = String.reverse path in
654681
let priority =
655682
(String.common_prefix_len rev path' * 2)
656-
+ if Preferences.is_preferred path then 1 else 0
683+
+ if Preferences.is_preferred_source path then 1 else 0
657684
in
658685
(priority, path))
659686
in

src/analysis/polarity_search.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ let directories ~global_modules env =
115115
List.fold_left
116116
~f:(fun l name ->
117117
let lident = Longident.Lident name in
118-
match Env.find_module_by_name lident env with
118+
match Env.find_module_by_name_lazy lident env with
119119
| exception _ -> l
120120
| _ -> Trie (name, lident, lazy (explore lident env)) :: l)
121121
~init:[] global_modules
@@ -138,7 +138,7 @@ let execute_query query env dirs =
138138
in
139139
let rec recurse acc (Trie (_, dir, children)) =
140140
match
141-
ignore (Env.find_module_by_name dir env);
141+
ignore (Env.find_module_by_name_lazy dir env);
142142
Lazy.force children
143143
with
144144
| children ->

src/analysis/syntax_doc.ml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,12 @@ let get_mode_doc mode =
225225
Some "The mutable parts of values with this mode can be fully accessed"
226226
| Comonadic Portability, Nonportable ->
227227
Some
228-
"Values with this mode cannot be sent to other threads, in order to \
229-
avoid data races."
228+
"Values with this mode cannot be sent to or shared with other threads, \
229+
in order to avoid data races."
230+
| Comonadic Portability, Shareable ->
231+
Some
232+
"Values with this mode can be shared with (but not sent to) other \
233+
threads without causing data races"
230234
| Comonadic Portability, Portable ->
231235
Some
232236
"Values with this mode can be sent to other threads without causing \
@@ -263,6 +267,9 @@ let get_mode_doc mode =
263267
Some "Functions with this mode may be executed concurrently."
264268
| Comonadic Forkable, Unforkable ->
265269
Some "Functions with this mode cannot be executed concurrently."
270+
| Monadic Staticity, Static -> Some "The value is known at compile-time."
271+
| Monadic Staticity, Dynamic ->
272+
Some "The value is not known at compile-time."
266273
in
267274
let doc_url =
268275
let subpage =
@@ -276,6 +283,7 @@ let get_mode_doc mode =
276283
| Monadic Visibility -> "modes/intro/"
277284
| Comonadic Statefulness -> "modes/intro/"
278285
| Comonadic Forkable -> "modes/intro/"
286+
| Monadic Staticity -> "modes/intro/"
279287
in
280288
syntax_doc_url Oxcaml subpage
281289
in

src/analysis/type_search.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let compute_values query env lident acc =
116116

117117
let values_from_module query env lident acc =
118118
let rec aux acc lident =
119-
match Env.find_module_by_name lident env with
119+
match Env.find_module_by_name_lazy lident env with
120120
| exception _ -> acc
121121
| _ ->
122122
let acc = compute_values query env (Some lident) acc in

src/analysis/type_utils.ml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ let parse_longident lid =
5959
with Parser_raw.Error -> None
6060

6161
let lookup_module name env =
62-
let path, md = Env.find_module_by_name name env in
63-
(path, md.Types.md_type, md.Types.md_attributes)
62+
let path, md = Env.find_module_by_name_lazy name env in
63+
(path, md.md_type, md.md_attributes)
6464

6565
let verbosity = ref Verbosity.default
6666

@@ -155,22 +155,22 @@ module Printtyp = struct
155155
let_ref verbosity v (fun () -> wrap_printing_env env f)
156156
end
157157

158-
let si_modtype_opt = function
159-
| Types.Sig_modtype (_, m, _) -> m.mtd_type
160-
| Types.Sig_module (_, _, m, _, _) -> Some m.md_type
158+
let si_modtype_opt : Subst.Lazy.signature_item -> _ = function
159+
| Sig_modtype (_, m, _) -> m.mtd_type
160+
| Sig_module (_, _, m, _, _) -> Some m.md_type
161161
| _ -> None
162162

163163
(* Check if module is smaller (= has less definition, counting nested ones)
164164
* than a particular threshold. Return (Some n) if module has size n, or None
165165
* otherwise (module is bigger than threshold).
166166
* Used to skip printing big modules in completion. *)
167-
let rec mod_smallerthan n m =
167+
let rec mod_smallerthan n (m : Subst.Lazy.module_type) =
168168
if n < 0 then None
169169
else
170-
let open Types in
171170
match m with
172171
| Mty_ident _ -> Some 1
173172
| Mty_signature s -> begin
173+
let s = Subst.Lazy.force_signature_once s in
174174
match List.length_lessthan n s with
175175
| None -> None
176176
| Some _ ->
@@ -190,17 +190,15 @@ let rec mod_smallerthan n m =
190190
| Some n', _ -> Some (succ n')
191191
end
192192
end
193-
| Mty_functor _ ->
194-
let m1, m2 = unpack_functor m in
195-
begin
196-
match (mod_smallerthan n m2, m1) with
197-
| None, _ -> None
198-
| result, Unit -> result
199-
| Some n1, Named (_, mt) -> (
200-
match mod_smallerthan (n - n1) mt with
201-
| None -> None
202-
| Some n2 -> Some (n1 + n2))
203-
end
193+
| Mty_functor (m1, m2) -> begin
194+
match (mod_smallerthan n m2, m1) with
195+
| None, _ -> None
196+
| result, Unit -> result
197+
| Some n1, Named (_, mt) -> (
198+
match mod_smallerthan (n - n1) mt with
199+
| None -> None
200+
| Some n2 -> Some (n1 + n2))
201+
end
204202
| _ -> Some 1
205203

206204
let print_short_modtype verbosity env ppf md =
@@ -209,7 +207,9 @@ let print_short_modtype verbosity env ppf md =
209207
match mod_smallerthan 1000 md with
210208
| None when verbosity = 0 ->
211209
Format.pp_print_string ppf "(* large signature, repeat to confirm *)"
212-
| _ -> Printtyp.modtype env ppf md
210+
| _ ->
211+
let md = Subst.Lazy.force_modtype md in
212+
Printtyp.modtype env ppf md
213213

214214
let print_type_with_decl ~verbosity env ppf typ =
215215
match verbosity with
@@ -260,13 +260,13 @@ let print_type ppf verbosity env lid =
260260
end
261261

262262
let print_modtype ppf verbosity env lid =
263-
let _p, mtd = Env.find_modtype_by_name lid.Asttypes.txt env in
263+
let _p, mtd = Env.find_modtype_by_name_lazy lid.Asttypes.txt env in
264264
match mtd.mtd_type with
265265
| Some mt -> print_short_modtype verbosity env ppf mt
266266
| None -> Format.pp_print_string ppf "(* abstract module *)"
267267

268268
let print_modpath ppf verbosity env lid =
269-
let _path, md = Env.find_module_by_name lid.Asttypes.txt env in
269+
let _path, md = Env.find_module_by_name_lazy lid.Asttypes.txt env in
270270
print_short_modtype verbosity env ppf md.md_type
271271

272272
let print_cstr_desc ppf cstr_desc =

src/analysis/type_utils.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
than a particular threshold. Return (Some n) if module has size n, or None
5151
otherwise (module is bigger than threshold).
5252
Used to skip printing big modules in completion. *)
53-
val mod_smallerthan : int -> Types.module_type -> int option
53+
val mod_smallerthan : int -> Subst.Lazy.module_type -> int option
5454

5555
(** [type_in_env env ppf input] parses [input] and prints its type on [ppf].
5656
Returning true if it printed a type, false otherwise. *)
@@ -76,7 +76,7 @@ val print_type_with_decl :
7676
(** [lookup_module] is a fancier version of [Env.lookup_module] that also
7777
returns the module type. *)
7878
val lookup_module :
79-
Longident.t -> Env.t -> Path.t * Types.module_type * Parsetree.attributes
79+
Longident.t -> Env.t -> Path.t * Subst.Lazy.module_type * Parsetree.attributes
8080

8181
(** [read_doc_attributes] looks for a docstring in an attribute list. *)
8282
val read_doc_attributes : Parsetree.attributes -> (string * Location.t) option

src/kernel/mconfig.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ let ocaml_ignored_flags =
447447
"-dlinear";
448448
"-dparsetree";
449449
"-dshape";
450+
"-dslambda";
450451
"-drawclambda";
451452
"-drawflambda";
452453
"-drawlambda";
@@ -622,6 +623,10 @@ let ocaml_ignored_flags =
622623
"-fno-avx2";
623624
"-favx";
624625
"-fno-avx";
626+
"-ffma";
627+
"-fno-fma";
628+
"-ff16c";
629+
"-fno-f16c";
625630
"-dllvmir";
626631
"-keep-llvmir";
627632
"-llvm-backend";
@@ -632,9 +637,17 @@ let ocaml_ignored_flags =
632637
"-no-cfg-prologue-validate";
633638
"-cfg-prologue-shrink-wrap";
634639
"-no-cfg-prologue-shrink-wrap";
640+
"-cfg-value-propagation";
641+
"-no-cfg-value-propagation";
642+
"-cfg-value-propagation-float";
643+
"-no-cfg-value-propagation-float";
635644
"-gdwarf-pedantic";
636645
"-ddwarf-metrics";
637-
"-afl-instrument"
646+
"-afl-instrument";
647+
"-probes";
648+
"-no-probes";
649+
"-probes-optimized";
650+
"-no-probes-optimized"
638651
]
639652

640653
let ocaml_ignored_parametrized_flags =
@@ -671,8 +684,8 @@ let ocaml_ignored_parametrized_flags =
671684
"-use-runtime";
672685
"-error-style";
673686
"-dump-dir";
674-
"-I-paths";
675-
"-H-paths";
687+
"-I-manifest";
688+
"-H-manifest";
676689
(* flambda-backend specific *)
677690
"-extension";
678691
"-extension-universe";

0 commit comments

Comments
 (0)