Skip to content

Commit 7b453ea

Browse files
committed
ocamlformat 0.27.0
1 parent 3b271e7 commit 7b453ea

Some content is hidden

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

56 files changed

+328
-273
lines changed

.ocamlformat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
profile = default
2-
version = 0.26.2
2+
version = 0.27.0
33

44
field-space = tight-decl
55
break-cases = toplevel
@@ -9,3 +9,4 @@ space-around-arrays = false
99
space-around-lists = false
1010
space-around-records = false
1111
space-around-variants = false
12+
parse-docstrings = false

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ module Decl = struct
555555
let refIsBelow (pos : Lexing.position) =
556556
decl.pos.pos_fname <> pos.pos_fname
557557
|| decl.pos.pos_cnum < pos.pos_cnum
558-
&& (* not a function defined inside a function, e.g. not a callback *)
558+
&&
559+
(* not a function defined inside a function, e.g. not a callback *)
559560
decl.posEnd.pos_cnum < pos.pos_cnum
560561
in
561562
refs |> PosSet.exists refIsBelow

analysis/src/SignatureHelp.ml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -553,44 +553,44 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
553553
let offset = ref 0 in
554554
Some
555555
(`InlineRecord
556-
(fields
557-
|> List.map (fun (field : field) ->
558-
let startOffset = !offset in
559-
let argText =
560-
Printf.sprintf "%s%s: %s" field.fname.txt
561-
(if field.optional then "?" else "")
562-
(Shared.typeToString
563-
(if field.optional then
564-
Utils.unwrapIfOption field.typ
565-
else field.typ))
566-
in
567-
let endOffset =
568-
startOffset + String.length argText
569-
in
570-
offset := endOffset + String.length ", ";
571-
(argText, field, (startOffset, endOffset)))))
556+
(fields
557+
|> List.map (fun (field : field) ->
558+
let startOffset = !offset in
559+
let argText =
560+
Printf.sprintf "%s%s: %s" field.fname.txt
561+
(if field.optional then "?" else "")
562+
(Shared.typeToString
563+
(if field.optional then
564+
Utils.unwrapIfOption field.typ
565+
else field.typ))
566+
in
567+
let endOffset =
568+
startOffset + String.length argText
569+
in
570+
offset := endOffset + String.length ", ";
571+
(argText, field, (startOffset, endOffset)))))
572572
| Args [(typ, _)] ->
573573
Some
574574
(`SingleArg
575-
( typ |> Shared.typeToString,
576-
docsForLabel ~file:full.file ~package:full.package
577-
~supportsMarkdownLinks typ ))
575+
( typ |> Shared.typeToString,
576+
docsForLabel ~file:full.file ~package:full.package
577+
~supportsMarkdownLinks typ ))
578578
| Args args ->
579579
let offset = ref 0 in
580580
Some
581581
(`TupleArg
582-
(args
583-
|> List.map (fun (typ, _) ->
584-
let startOffset = !offset in
585-
let argText = typ |> Shared.typeToString in
586-
let endOffset =
587-
startOffset + String.length argText
588-
in
589-
offset := endOffset + String.length ", ";
590-
( argText,
591-
docsForLabel ~file:full.file ~package:full.package
592-
~supportsMarkdownLinks typ,
593-
(startOffset, endOffset) ))))
582+
(args
583+
|> List.map (fun (typ, _) ->
584+
let startOffset = !offset in
585+
let argText = typ |> Shared.typeToString in
586+
let endOffset =
587+
startOffset + String.length argText
588+
in
589+
offset := endOffset + String.length ", ";
590+
( argText,
591+
docsForLabel ~file:full.file ~package:full.package
592+
~supportsMarkdownLinks typ,
593+
(startOffset, endOffset) ))))
594594
in
595595
let label =
596596
constructor.name ^ "("

compiler/bsb/bsb_exception.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ let print (fmt : Format.formatter) (x : error) =
4040
| Conflict_module (modname, dir1, dir2) ->
4141
Format.fprintf fmt
4242
"@{<error>Error:@} %s found in two directories: (%s, %s)\n\
43-
File names must be unique per project" modname dir1 dir2
43+
File names must be unique per project"
44+
modname dir1 dir2
4445
| No_implementation modname ->
4546
Format.fprintf fmt "@{<error>Error:@} %s does not have implementation file"
4647
modname
@@ -51,12 +52,14 @@ let print (fmt : Format.formatter) (x : error) =
5152
"File \"bsconfig.json\", line 1\n\
5253
@{<error>Error:@} package @{<error>%s@} is not found\n\
5354
It's the basic, required package. If you have it installed globally,\n\
54-
Please run `npm link rescript` to make it available" name
55+
Please run `npm link rescript` to make it available"
56+
name
5557
else
5658
Format.fprintf fmt
5759
"File \"bsconfig.json\", line 1\n\
5860
@{<error>Error:@} package @{<error>%s@} not found or built\n\
59-
- Did you install it?" name
61+
- Did you install it?"
62+
name
6063
| Json_config (pos, s) ->
6164
Format.fprintf fmt
6265
"File %S, line %d:\n\

compiler/bsb/bsb_ninja_check.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ let record ~(package_kind : Bsb_package_kind.t) ~per_proj_dir ~file
114114
record_global_atime buf Sys.executable_name;
115115
Ext_list.iter config.ppx_files (fun {name; args = _} ->
116116
try record_global_atime buf name
117-
with _ -> (* record the ppx files as a best effort *)
118-
());
117+
with _ ->
118+
(* record the ppx files as a best effort *)
119+
());
119120
let oc = open_out_bin file in
120121
Ext_buffer.output_buffer oc buf;
121122
close_out oc

compiler/bsb/bsb_ninja_gen.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ let emit_bsc_lib_includes (bs_dependencies : Bsb_config_types.dependencies)
4040
let all_includes source_dirs =
4141
source_dirs
4242
@ Ext_list.map bs_dependencies (fun x -> x.package_install_path)
43-
@ (* for external includes, if it is absolute path, leave it as is
43+
@
44+
(* for external includes, if it is absolute path, leave it as is
4445
for relative path './xx', we need '../.././x' since we are in
4546
[lib/bs], [build] is different from merlin though
4647
*)

compiler/bsb/bsb_parse_sources.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ and parse_sources (cxt : cxt) (sources : Ext_json_types.t) =
322322
| Arr file_groups -> parsing_arr_sources cxt file_groups.content
323323
| _ -> parsing_single_source cxt sources
324324

325-
let scan ~package_kind ~root ~cut_generators ~(* ~namespace *)
326-
ignored_dirs x : t =
325+
let scan ~package_kind ~root ~cut_generators
326+
~(* ~namespace *)
327+
ignored_dirs x : t =
327328
parse_sources
328329
{
329330
ignored_dirs;

compiler/bsb_helper/bsb_db_decode.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ and decode_single (x : string) (offset : cursor) : group =
5151
let modules = decode_modules x offset module_number in
5252
let dir_info_offset = !offset in
5353
let module_info_offset = String.index_from x dir_info_offset '\n' + 1 in
54-
let dir_length = Char.code x.[module_info_offset] - 48 (* Char.code '0'*) in
54+
let dir_length =
55+
Char.code x.[module_info_offset] - 48
56+
(* Char.code '0'*)
57+
in
5558
offset := module_info_offset + 1 + (dir_length * module_number) + 1;
5659
Group {modules; dir_info_offset; module_info_offset; dir_length})
5760
else Dummy

compiler/core/js_analyzer.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ let free_variables (stats : idents_stats) =
5858
| Fun {env}
5959
(* a optimization to avoid walking into function again
6060
if it's already comuted
61-
*) ->
61+
*)
62+
->
6263
stats.used_idents <-
6364
Set_ident.union (Js_fun_env.get_unbounded env) stats.used_idents
6465
| _ -> super.expression self exp);

compiler/core/js_cmj_format.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ let get_result mid_val =
113113
match mid_val.persistent_closed_lambda with
114114
| Some
115115
(Lconst
116-
(Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false))
116+
(Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false))
117117
| None ->
118118
mid_val
119119
| Some _ ->
@@ -131,8 +131,10 @@ let rec binary_search_aux arr lo hi (key : string) =
131131
let lo_val = Array.unsafe_get arr lo in
132132
if lo_val.name = key then get_result lo_val else not_found key
133133
else binary_search_aux arr lo mid key
134-
else if (* a[lo] =< a[mid] < key <= a[hi] *)
135-
lo = mid then
134+
else if
135+
(* a[lo] =< a[mid] < key <= a[hi] *)
136+
lo = mid
137+
then
136138
let hi_val = Array.unsafe_get arr hi in
137139
if hi_val.name = key then get_result hi_val else not_found key
138140
else binary_search_aux arr mid hi key

compiler/core/js_dump.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t)
436436
since it can be either [int] or [string]
437437
*)
438438
and pp_one_case_clause :
439-
'a. _ -> P.t -> (P.t -> 'a -> unit) -> 'a * J.case_clause -> _ =
439+
'a. _ -> P.t -> (P.t -> 'a -> unit) -> 'a * J.case_clause -> _ =
440440
fun cxt f pp_cond
441441
(switch_case, ({switch_body; should_break; comment} : J.case_clause)) ->
442442
P.newline f;
@@ -467,8 +467,7 @@ and pp_one_case_clause :
467467
cxt
468468

469469
and loop_case_clauses :
470-
'a. cxt -> P.t -> (P.t -> 'a -> unit) -> ('a * J.case_clause) list -> cxt
471-
=
470+
'a. cxt -> P.t -> (P.t -> 'a -> unit) -> ('a * J.case_clause) list -> cxt =
472471
fun cxt f pp_cond cases ->
473472
Ext_list.fold_left cases cxt (fun acc x -> pp_one_case_clause acc f pp_cond x)
474473

@@ -693,7 +692,8 @@ and expression_desc cxt ~(level : int) f x : cxt =
693692
{[ 0. - x ]}
694693
{[ 0.00 - x ]}
695694
{[ 0.000 - x ]}
696-
*) ->
695+
*)
696+
->
697697
P.cond_paren_group f (level > 13) (fun _ ->
698698
P.string f
699699
(match desc with
@@ -1214,7 +1214,8 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
12141214
semi f;
12151215
cxt)
12161216
(* There MUST be a space between the return and its
1217-
argument. A line return will not work *))
1217+
argument. A line return will not work *)
1218+
)
12181219
| Int_switch (e, cc, def) ->
12191220
P.string f L.switch;
12201221
P.space f;

compiler/core/js_exp_make.mli

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,22 @@ val external_var :
7676
val ml_module_as_var : ?comment:string -> ?dynamic_import:bool -> Ident.t -> t
7777

7878
val runtime_call :
79-
string -> (* module_name *)
80-
string -> (* fn_name *)
81-
t list -> (* args *)
82-
t
79+
string ->
80+
(* module_name *)
81+
string ->
82+
(* fn_name *)
83+
t list ->
84+
(* args *)
85+
t
8386

8487
val pure_runtime_call :
85-
string -> (* module_name *)
86-
string -> (* fn_name *)
87-
t list -> (* args *)
88-
t
88+
string ->
89+
(* module_name *)
90+
string ->
91+
(* fn_name *)
92+
t list ->
93+
(* args *)
94+
t
8995

9096
val runtime_ref : string -> string -> t
9197

compiler/core/js_pass_scope.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ let record_scope_pass =
198198
since it's in the loop
199199
200200
TODO: we should also
201-
*) -> (
201+
*)
202+
-> (
202203
match value with
203204
| None ->
204205
add_loop_mutable_variable state ident

compiler/core/lam_compile.ml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -509,26 +509,22 @@ let compile output_prefix =
509509
Ext_list.fold_left rest acc (fun acc x ->
510510
Js_output.append_output acc (compile_recursive_lets_aux cxt x)))
511511
and compile_general_cases :
512-
'a.
513-
make_exp:('a -> J.expression) ->
514-
eq_exp:
515-
('a option ->
516-
J.expression ->
517-
'a option ->
518-
J.expression ->
519-
J.expression) ->
520-
cxt:Lam_compile_context.t ->
521-
switch:
522-
(?default:J.block ->
523-
?declaration:Lam_compat.let_kind * Ident.t ->
524-
_ ->
525-
('a * J.case_clause) list ->
526-
J.statement) ->
527-
switch_exp:J.expression ->
528-
default:default_case ->
529-
?merge_cases:('a -> 'a -> bool) ->
530-
('a * Lam.t) list ->
531-
J.block =
512+
'a.
513+
make_exp:('a -> J.expression) ->
514+
eq_exp:
515+
('a option -> J.expression -> 'a option -> J.expression -> J.expression) ->
516+
cxt:Lam_compile_context.t ->
517+
switch:
518+
(?default:J.block ->
519+
?declaration:Lam_compat.let_kind * Ident.t ->
520+
_ ->
521+
('a * J.case_clause) list ->
522+
J.statement) ->
523+
switch_exp:J.expression ->
524+
default:default_case ->
525+
?merge_cases:('a -> 'a -> bool) ->
526+
('a * Lam.t) list ->
527+
J.block =
532528
fun (type a) ~(make_exp : a -> J.expression)
533529
~(eq_exp :
534530
a option -> J.expression -> a option -> J.expression -> J.expression)

compiler/core/lam_compile_primitive.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,5 +612,6 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
612612
(* let parm = Ident.create "prim" in
613613
Lfunction(Curried, [parm],
614614
Matching.inline_lazy_force (Lvar parm) Location.none)
615-
It is inlined, this should not appear here *) ->
615+
It is inlined, this should not appear here *)
616+
->
616617
assert false

compiler/core/lam_pass_lets_dce.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ let lets_helper (count_var : Ident.t -> Lam_pass_count.used_info) lam : Lam.t =
5959
Note for some constant which is not
6060
inlined, we can still record it and
6161
do constant folding independently
62-
*) ->
62+
*)
63+
->
6364
Hash_ident.add subst v (simplif l1);
6465
simplif l2
6566
| _, Lconst (Const_string {s; unicode = false}) ->

compiler/core/lam_pass_remove_alias.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
156156
match Hash_ident.find_opt meta.ident_tbl v with
157157
| Some
158158
(FunctionId
159-
{
160-
lambda =
161-
Some
162-
( Lfunction ({params; body; attr = {is_a_functor}} as m),
163-
rec_flag );
164-
})
159+
{
160+
lambda =
161+
Some
162+
( Lfunction ({params; body; attr = {is_a_functor}} as m),
163+
rec_flag );
164+
})
165165
when Lam_analysis.lfunction_can_be_inlined m ->
166166
if Ext_list.same_length ap_args params then
167167
if is_a_functor (* && (Set_ident.mem v meta.export_idents) && false *)
@@ -170,7 +170,6 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
170170
if so, maybe not since in that case,
171171
we are going to have two copy?
172172
*)
173-
174173
(* Check: recursive applying may result in non-termination *)
175174
(* Ext_log.dwarn __LOC__ "beta .. %s/%d" v.name v.stamp ; *)
176175
simpl

compiler/core/lam_stats_export.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ let values_of_export (meta : Lam_stats.t) (export_map : Lam.t Map_ident.t) :
5555
match optlam with
5656
| Some
5757
(Lconst
58-
( Const_js_null | Const_js_undefined _ | Const_js_true
59-
| Const_js_false ))
58+
( Const_js_null | Const_js_undefined _ | Const_js_true
59+
| Const_js_false ))
6060
| None ->
6161
optlam
6262
| Some lambda ->

0 commit comments

Comments
 (0)