Skip to content

Commit 3d4b7f4

Browse files
committed
ocamlformat 0.26.0
1 parent 260d770 commit 3d4b7f4

33 files changed

+273
-273
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
profile = default
2-
version = 0.22.4
2+
version = 0.26.0
33

44
field-space = tight-decl
55
break-cases = toplevel

dune-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
(ocaml
2222
(>= 4.10))
2323
(ocamlformat
24-
(= 0.22.4))
24+
(= 0.26.0))
2525
(cppo
2626
(= 1.6.9))
2727
(js_of_ocaml-compiler

jscomp/frontend/ast_attributes.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ let process_method_attributes_rev (attrs : t) =
4141
| None -> true
4242
| Some e -> Ast_payload.assert_bool_lit e),
4343
undefined )
44-
| "undefined" -> (
44+
| "undefined" ->
4545
( null,
4646
match opt_expr with
4747
| None -> true
48-
| Some e -> Ast_payload.assert_bool_lit e ))
48+
| Some e -> Ast_payload.assert_bool_lit e )
4949
| "nullable" -> (
5050
match opt_expr with
5151
| None -> (true, true)

jscomp/frontend/ast_derive_abstract.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ let handleTdcl light (tdcl : Parsetree.type_declaration) :
8484
Ext_list.fold_right label_declarations
8585
( [],
8686
(if has_optional_field then
87-
Ast_compatible.arrow ~loc (Ast_literal.type_unit ()) core_type
88-
else core_type),
87+
Ast_compatible.arrow ~loc (Ast_literal.type_unit ()) core_type
88+
else core_type),
8989
[] )
9090
(fun ({
9191
pld_name = {txt = label_name; loc = label_loc} as pld_name;
@@ -109,15 +109,15 @@ let handleTdcl light (tdcl : Parsetree.type_declaration) :
109109
( Ast_compatible.opt_arrow ~loc:pld_loc label_name pld_type maker,
110110
Val.mk ~loc:pld_loc
111111
(if light then pld_name
112-
else {pld_name with txt = pld_name.txt ^ "Get"})
112+
else {pld_name with txt = pld_name.txt ^ "Get"})
113113
~attrs:get_optional_attrs ~prim
114114
(Ast_compatible.arrow ~loc core_type optional_type)
115115
:: acc )
116116
else
117117
( Ast_compatible.label_arrow ~loc:pld_loc label_name pld_type maker,
118118
Val.mk ~loc:pld_loc
119119
(if light then pld_name
120-
else {pld_name with txt = pld_name.txt ^ "Get"})
120+
else {pld_name with txt = pld_name.txt ^ "Get"})
121121
~attrs:get_attrs
122122
~prim:
123123
((* Not needed actually*)

jscomp/frontend/ast_derive_js_mapper.ml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ let init () =
213213
Ast_comb.single_non_rec_value patFromJs
214214
(Ast_compatible.fun_ (Pat.var pat_param)
215215
(if createType then
216-
Exp.let_ Nonrecursive
217-
[Vb.mk (Pat.var pat_param) (exp_param +: newType)]
218-
(Exp.constraint_ obj_exp core_type)
219-
else Exp.constraint_ obj_exp core_type))
216+
Exp.let_ Nonrecursive
217+
[Vb.mk (Pat.var pat_param) (exp_param +: newType)]
218+
(Exp.constraint_ obj_exp core_type)
219+
else Exp.constraint_ obj_exp core_type))
220220
in
221221
let rest = [toJs; fromJs] in
222222
if createType then eraseTypeStr :: newTypeStr :: rest else rest
@@ -239,16 +239,17 @@ let init () =
239239
));
240240
Ast_comb.single_non_rec_value {loc; txt = revMap}
241241
(if has_bs_as then
242-
Exp.extension
243-
( {txt = "raw"; loc},
244-
PStr
245-
[Str.eval (Exp.constant (Const.string revData))]
246-
)
247-
else expMap);
242+
Exp.extension
243+
( {txt = "raw"; loc},
244+
PStr
245+
[
246+
Str.eval (Exp.constant (Const.string revData));
247+
] )
248+
else expMap);
248249
toJsBody
249250
(if has_bs_as then
250-
app2 unsafeIndexGetExp expMap exp_param
251-
else app1 eraseTypeExp exp_param);
251+
app2 unsafeIndexGetExp expMap exp_param
252+
else app1 eraseTypeExp exp_param);
252253
Ast_comb.single_non_rec_value patFromJs
253254
(Ast_compatible.fun_ (Pat.var pat_param)
254255
(let result =

jscomp/frontend/ast_derive_projector.ml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,33 @@ let init () =
6060
Ast_comb.single_non_rec_value
6161
{loc; txt = little_con_name}
6262
(if arity = 0 then
63-
(*TODO: add a prefix, better inter-op with FFI *)
64-
Exp.constraint_
65-
(Exp.construct
66-
{loc; txt = Longident.Lident con_name}
67-
None)
68-
annotate_type
69-
else
70-
let vars =
71-
Ext_list.init arity (fun x ->
72-
"param_" ^ string_of_int x)
73-
in
74-
let exp =
75-
Exp.constraint_
76-
(Exp.construct
77-
{loc; txt = Longident.Lident con_name}
78-
@@ Some
79-
(if arity = 1 then
80-
Exp.ident {loc; txt = Lident (List.hd vars)}
81-
else
82-
Exp.tuple
83-
(Ext_list.map vars (fun x ->
84-
Exp.ident {loc; txt = Lident x}))))
85-
annotate_type
86-
in
87-
Ext_list.fold_right vars exp (fun var b ->
88-
Ast_compatible.fun_ (Pat.var {loc; txt = var}) b)))
63+
(*TODO: add a prefix, better inter-op with FFI *)
64+
Exp.constraint_
65+
(Exp.construct
66+
{loc; txt = Longident.Lident con_name}
67+
None)
68+
annotate_type
69+
else
70+
let vars =
71+
Ext_list.init arity (fun x ->
72+
"param_" ^ string_of_int x)
73+
in
74+
let exp =
75+
Exp.constraint_
76+
(Exp.construct
77+
{loc; txt = Longident.Lident con_name}
78+
@@ Some
79+
(if arity = 1 then
80+
Exp.ident
81+
{loc; txt = Lident (List.hd vars)}
82+
else
83+
Exp.tuple
84+
(Ext_list.map vars (fun x ->
85+
Exp.ident {loc; txt = Lident x}))))
86+
annotate_type
87+
in
88+
Ext_list.fold_right vars exp (fun var b ->
89+
Ast_compatible.fun_ (Pat.var {loc; txt = var}) b)))
8990
| Ptype_abstract | Ptype_open ->
9091
Ast_derive_util.notApplicable tdcl.ptype_loc derivingName;
9192
[]

jscomp/frontend/ast_external_process.ml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -882,22 +882,22 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type)
882882
let arg_label = param_type.label in
883883
let ty = param_type.ty in
884884
(if i = 0 && splice then
885-
match arg_label with
886-
| Optional _ ->
887-
Location.raise_errorf ~loc
888-
"%@variadic expect the last type to be a non optional"
889-
| Labelled _ | Nolabel -> (
890-
if ty.ptyp_desc = Ptyp_any then
885+
match arg_label with
886+
| Optional _ ->
891887
Location.raise_errorf ~loc
892-
"%@variadic expect the last type to be an array";
893-
if spec_of_ptyp true ty <> Nothing then
894-
Location.raise_errorf ~loc
895-
"%@variadic expect the last type to be an array";
896-
match ty.ptyp_desc with
897-
| Ptyp_constr ({txt = Lident "array"; _}, [_]) -> ()
898-
| _ ->
899-
Location.raise_errorf ~loc
900-
"%@variadic expect the last type to be an array"));
888+
"%@variadic expect the last type to be a non optional"
889+
| Labelled _ | Nolabel -> (
890+
if ty.ptyp_desc = Ptyp_any then
891+
Location.raise_errorf ~loc
892+
"%@variadic expect the last type to be an array";
893+
if spec_of_ptyp true ty <> Nothing then
894+
Location.raise_errorf ~loc
895+
"%@variadic expect the last type to be an array";
896+
match ty.ptyp_desc with
897+
| Ptyp_constr ({txt = Lident "array"; _}, [_]) -> ()
898+
| _ ->
899+
Location.raise_errorf ~loc
900+
"%@variadic expect the last type to be an array"));
901901
let ( (arg_label : External_arg_spec.label_noname),
902902
arg_type,
903903
new_arg_types ) =
@@ -974,8 +974,7 @@ let pval_prim_of_option_labels (labels : (bool * string Asttypes.loc) list)
974974
(ends_with_unit : bool) =
975975
let arg_kinds =
976976
Ext_list.fold_right labels
977-
(if ends_with_unit then [External_arg_spec.empty_kind Extern_unit]
978-
else [])
977+
(if ends_with_unit then [External_arg_spec.empty_kind Extern_unit] else [])
979978
(fun (is_option, p) arg_kinds ->
980979
let label_name = p.txt in
981980
let obj_arg_label =

jscomp/frontend/bs_builtin_ppx.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
533533
(* Dynamic import of module transformation: module M = @res.await Belt.List *)
534534
| Pstr_module
535535
({pmb_expr = {pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as me}
536-
as mb)
536+
as mb)
537537
when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes ->
538538
let item = self.structure_item self item in
539539
let safe_module_type_name = local_module_type_name txt in
@@ -580,8 +580,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
580580
match pvb_expr.pexp_desc with
581581
| Pexp_letmodule
582582
( _,
583-
({pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as
584-
me),
583+
({pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as me),
585584
_ )
586585
when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes
587586
-> (

jscomp/frontend/external_ffi_types.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ let inline_float_primitive (i : string) : string list =
296296
let rec ffi_bs_aux acc (params : External_arg_spec.params) =
297297
match params with
298298
| {arg_type = Nothing; arg_label = Arg_empty}
299-
(* same as External_arg_spec.dummy*)
299+
(* same as External_arg_spec.dummy*)
300300
:: rest ->
301301
ffi_bs_aux (acc + 1) rest
302302
| _ :: _ -> -1

jscomp/gentype/EmitJs.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
156156
match type_ with
157157
| Function
158158
({argTypes = [{aType = Object (closedFlag, fields); aName}]; retType}
159-
as function_)
159+
as function_)
160160
when retType |> EmitType.isTypeFunctionComponent ~fields ->
161161
(* JSX V3 *)
162162
let fields =
@@ -178,7 +178,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
178178
Function function_
179179
| Function
180180
({argTypes = [{aType = Ident {name} as propsType; aName}]; retType} as
181-
function_)
181+
function_)
182182
when Filename.check_suffix name "props"
183183
&& retType |> EmitType.isTypeFunctionComponent ~fields:[] -> (
184184
match inlineOneLevel propsType with
@@ -305,7 +305,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
305305
Some {HookType.propsType; resolvedTypeName; typeVars} )
306306
| Function
307307
({argTypes = [{aType = Ident {name} as propsType}]; retType} as
308-
function_)
308+
function_)
309309
when Filename.check_suffix name "props"
310310
&& retType |> EmitType.isTypeFunctionComponent ~fields:[] ->
311311
let compType =

jscomp/gentype/EmitType.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ let emitExportType ~(config : Config.t) ~emitters ~nameAs ~opaque ~type_
364364
|> Emitters.export ~emitters
365365
else
366366
(if isInterface && config.exportInterfaces then
367-
docString ^ "export interface " ^ resolvedTypeName ^ typeParamsString ^ " "
368-
else
369-
"// tslint:disable-next-line:interface-over-type-literal\n" ^ docString
370-
^ "export type " ^ resolvedTypeName ^ typeParamsString ^ " = ")
367+
docString ^ "export interface " ^ resolvedTypeName ^ typeParamsString
368+
^ " "
369+
else
370+
"// tslint:disable-next-line:interface-over-type-literal\n" ^ docString
371+
^ "export type " ^ resolvedTypeName ^ typeParamsString ^ " = ")
371372
^ (match type_ with
372373
| _ -> type_ |> typeToString ~config ~typeNameIsInterface)
373374
^ ";" ^ exportNameAs

jscomp/gentype/GenTypeMain.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ let processCmtFile cmt =
167167
else (
168168
outputFile |> GeneratedFiles.logFileAction NoMatch;
169169
if Sys.file_exists outputFile then Sys.remove outputFile)
170-
[@@live]
170+
[@@live]

jscomp/gentype/TranslateCoreType.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ and translateCoreType_ ~config ~typeVarsGen
120120
| Ttyp_object (tObj, closedFlag) ->
121121
let getFieldType objectField =
122122
match objectField with
123-
| Typedtree.OTtag ({txt = name}, _, t) -> (
123+
| Typedtree.OTtag ({txt = name}, _, t) ->
124124
( name,
125125
match name |> Runtime.isMutableObjectField with
126126
| true -> {dependencies = []; type_ = ident ""}
127-
| false -> t |> translateCoreType_ ~config ~typeVarsGen ~typeEnv ))
127+
| false -> t |> translateCoreType_ ~config ~typeVarsGen ~typeEnv )
128128
| OTinherit t ->
129129
("Inherit", t |> translateCoreType_ ~config ~typeVarsGen ~typeEnv)
130130
in

jscomp/gentype/TranslateTypeDeclarations.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver
118118
let fields =
119119
fieldTranslations
120120
|> List.map
121-
(fun (name, mutable_, {TranslateTypeExprFromTypes.type_}, docString)
122-
->
121+
(fun
122+
(name, mutable_, {TranslateTypeExprFromTypes.type_}, docString) ->
123123
let optional, type1 =
124124
match type_ with
125125
| Option type1 when isOptional name -> (Optional, type1)

jscomp/syntax/cli/res_cli.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module Color = struct
9090
| Format.String_tag "dim" -> [Dim]
9191
| Format.String_tag "filename" -> [FG Cyan]
9292
| _ -> raise Not_found
93-
[@@raises Not_found]
93+
[@@raises Not_found]
9494

9595
let color_enabled = ref true
9696

@@ -305,7 +305,7 @@ module CliArgProcessor = struct
305305
in
306306
printEngine.printImplementation ~width ~filename
307307
~comments:parseResult.comments parsetree
308-
[@@raises exit]
308+
[@@raises exit]
309309
end
310310

311311
let () =
@@ -317,4 +317,4 @@ let () =
317317
~jsxVersion:!ResClflags.jsxVersion ~jsxModule:!ResClflags.jsxModule
318318
~jsxMode:!ResClflags.jsxMode ~typechecker:!ResClflags.typechecker
319319
!ResClflags.file)
320-
[@@raises exit]
320+
[@@raises exit]

jscomp/syntax/src/reactjs_jsx_v3.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ let jsxMapper ~config =
592592
pstr_desc =
593593
Pstr_primitive
594594
({pval_name = {txt = fnName}; pval_attributes; pval_type} as
595-
value_description);
595+
value_description);
596596
} as pstr -> (
597597
match List.filter React_jsx_common.hasAttr pval_attributes with
598598
| [] -> [item]
@@ -1035,7 +1035,7 @@ let jsxMapper ~config =
10351035
psig_desc =
10361036
Psig_value
10371037
({pval_name = {txt = fnName}; pval_attributes; pval_type} as
1038-
psig_desc);
1038+
psig_desc);
10391039
} as psig -> (
10401040
match List.filter React_jsx_common.hasAttr pval_attributes with
10411041
| [] -> [item]

jscomp/syntax/src/reactjs_jsx_v4.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,10 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
947947
| None -> makePropsPattern namedTypeList
948948
| Some _ -> makePropsPattern typVarsOfCoreType)
949949
(if hasForwardRef then
950-
Exp.fun_ nolabel None
951-
(Pat.var @@ Location.mknoloc "ref")
952-
innerExpression
953-
else innerExpression)
950+
Exp.fun_ nolabel None
951+
(Pat.var @@ Location.mknoloc "ref")
952+
innerExpression
953+
else innerExpression)
954954
in
955955
let fullExpression =
956956
if !Config.uncurried = Uncurried then
@@ -1250,8 +1250,8 @@ let transformSignatureItem ~config item =
12501250
psig_loc
12511251
((* If there is Nolabel arg, regard the type as ref in forwardRef *)
12521252
(if !hasForwardRef then
1253-
[(true, "ref", [], Location.none, refType Location.none)]
1254-
else [])
1253+
[(true, "ref", [], Location.none, refType Location.none)]
1254+
else [])
12551255
@ namedTypeList)
12561256
in
12571257
(* can't be an arrow because it will defensively uncurry *)

jscomp/syntax/src/res_comment.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let makeMultiLineComment ~loc ~docComment ~standalone txt =
4343
loc;
4444
style =
4545
(if docComment then if standalone then ModuleComment else DocComment
46-
else MultiLine);
46+
else MultiLine);
4747
prevTokEndPos = Lexing.dummy_pos;
4848
}
4949

0 commit comments

Comments
 (0)