Skip to content

Commit 363257e

Browse files
authored
Upgrade ocamlformat to 0.26.1 (#6493)
1 parent 2a37c94 commit 363257e

36 files changed

+286
-274
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,23 @@ jobs:
143143
144144
- name: Use OCaml ${{matrix.ocaml_compiler}}
145145
uses: ocaml/setup-ocaml@v2
146+
if: matrix.os != 'windows-latest'
146147
with:
147148
ocaml-compiler: ${{matrix.ocaml_compiler}}
148149
opam-pin: false
149150
opam-depext: false
150151

152+
- name: Use OCaml ${{matrix.ocaml_compiler}} (Win)
153+
uses: ocaml/setup-ocaml@v2
154+
if: matrix.os == 'windows-latest'
155+
with:
156+
ocaml-compiler: ${{matrix.ocaml_compiler}}
157+
opam-pin: false
158+
opam-depext: false
159+
opam-repositories: |
160+
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
161+
default: https://github.com/ocaml/opam-repository.git
162+
151163
- name: "Install OPAM dependencies"
152164
run: opam install . --deps-only
153165

.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.1
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.1))
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
@@ -896,22 +896,22 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type)
896896
let arg_label = param_type.label in
897897
let ty = param_type.ty in
898898
(if i = 0 && splice then
899-
match arg_label with
900-
| Optional _ ->
901-
Location.raise_errorf ~loc
902-
"%@variadic expect the last type to be a non optional"
903-
| Labelled _ | Nolabel -> (
904-
if ty.ptyp_desc = Ptyp_any then
899+
match arg_label with
900+
| Optional _ ->
905901
Location.raise_errorf ~loc
906-
"%@variadic expect the last type to be an array";
907-
if spec_of_ptyp true ty <> Nothing then
908-
Location.raise_errorf ~loc
909-
"%@variadic expect the last type to be an array";
910-
match ty.ptyp_desc with
911-
| Ptyp_constr ({txt = Lident "array"; _}, [_]) -> ()
912-
| _ ->
913-
Location.raise_errorf ~loc
914-
"%@variadic expect the last type to be an array"));
902+
"%@variadic expect the last type to be a non optional"
903+
| Labelled _ | Nolabel -> (
904+
if ty.ptyp_desc = Ptyp_any then
905+
Location.raise_errorf ~loc
906+
"%@variadic expect the last type to be an array";
907+
if spec_of_ptyp true ty <> Nothing then
908+
Location.raise_errorf ~loc
909+
"%@variadic expect the last type to be an array";
910+
match ty.ptyp_desc with
911+
| Ptyp_constr ({txt = Lident "array"; _}, [_]) -> ()
912+
| _ ->
913+
Location.raise_errorf ~loc
914+
"%@variadic expect the last type to be an array"));
915915
let ( (arg_label : External_arg_spec.label_noname),
916916
arg_type,
917917
new_arg_types ) =
@@ -988,8 +988,7 @@ let pval_prim_of_option_labels (labels : (bool * string Asttypes.loc) list)
988988
(ends_with_unit : bool) =
989989
let arg_kinds =
990990
Ext_list.fold_right labels
991-
(if ends_with_unit then [External_arg_spec.empty_kind Extern_unit]
992-
else [])
991+
(if ends_with_unit then [External_arg_spec.empty_kind Extern_unit] else [])
993992
(fun (is_option, p) arg_kinds ->
994993
let label_name = p.txt in
995994
let obj_arg_label =

jscomp/frontend/bs_builtin_ppx.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
549549
(* Dynamic import of module transformation: module M = @res.await Belt.List *)
550550
| Pstr_module
551551
({pmb_expr = {pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as me}
552-
as mb)
552+
as mb)
553553
when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes ->
554554
let item = self.structure_item self item in
555555
let safe_module_type_name = local_module_type_name txt in

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

0 commit comments

Comments
 (0)