CHANGES:
Highlight
-
* Support for OCaml 5.4
(#2717, #2720, #2732, #2733, #2735, @Julow, @Octachron, @cod1r, @EmileTrotignon)
OCamlformat now supports OCaml 5.4 syntax.
Module packing of the form((module M) : (module S))are no longer
rewritten to(module M : S)because these are now two different syntaxes. -
* Reduce indentation after
|> map (fun(#2694, @EmileTrotignon)
Notably, the indentation no longer depends on the length of the infix
operator, for example:(* before *) v |>>>>>> map (fun x -> x ) (* after *) v |>>>>>> map (fun x -> x )
@@ matchcan now also be on one line.
Added
-
Added option
module-indentoption (#2711, @HPRIOR) to control the indentation
of items within modules. This affects modules and signatures. For example,
module-indent=4:module type M = sig type t val f : (string * int) list -> int end
-
exp-grouping=preserveis now the default indefaultandocamlformat
profiles. This means that its now possible to usebegin ... endwithout
tweaking ocamlformat. (#2716, @EmileTrotignon)
Deprecated
- Starting in this release, ocamlformat can use cmdliner >= 2.0.0. When that is
the case, the tool no longer accepts unambiguous option names prefixes. For
example,--max-iteris not accepted anymore, you have to pass the full
option--max-iters. This does not apply to the keys in the.ocamlformat
configuration files, which have always required the full name.
See dbuenzli/cmdliner#200.
(#2680, @emillon)
Changed
-
* The formatting of infix extensions is now consistent with regular
formatting by construction. This reduces indentation inf @@ match%e
expressions to the level of indentation inf @@ match. Other unknown
inconsistencies might also be fixed. (#2676, @EmileTrotignon) -
* The spacing of infix attributes is now consistent across keywords. Every
keyword butbeginfunction, andfunhad attributes stuck to the keyword:
match[@a], butfun [@a]. Now its alsofun[@a]. (#2676, @EmileTrotignon) -
* The formatting of
let a = b in fun ...is now consistent with other
contexts likea ; fun .... A check for the syntaxlet a = fun ... in ...
was made more precise. (#2705, @EmileTrotignon) -
*
|> begin,~arg:begin,begin if,lazy begin,begin match,
begin funandmap li begin funcan now be printed on the same line, with
one less indentation level for the body of the inner expression.
(#2664, #2666, #2671, #2672, #2681, #2685, #2693, @EmileTrotignon)
For example :(* before *) begin fun x -> some code end (* after *) begin fun x -> some code end
-
*
break-struct=naturalnow also applies tosig ... end. (#2682, @EmileTrotignon)
Fixed
-
Fixed
wrap-comments=truenot working with the janestreet profile (#2645, @Julow)
Asterisk-prefixed comments are also now formatted the same way as with the
default profile. -
Fixed
nested-match=alignnot working withmatch%ext(#2648, @EmileTrotignon) -
Fixed the AST generated for bindings of the form
let pattern : type = function ...
(#2651, @v-gb) -
Ast_mapper.default_mappernow iterates on the location ofininlet+ .. in ..
(#2658, @v-gb) -
Fix missing parentheses in
let+ (Cstr _) : _ = _(#2661, @Julow)
This caused a crash as the generated code wasn't valid syntax. -
Fix bad indentation of
let%ext { ...(#2663, @EmileTrotignon)
withdock-collection-bracketsenabled. -
ocamlformat is now more robust when used as a library to print modified ASTs
(#2659, @v-gb) -
Fix crash due to edge case with asterisk-prefixed comments (#2674, @Julow)
-
Fix crash when formatting
mldfiles that cannot be lexed as ocaml (e.g.
containing LaTeX or C code) (#2684, @emillon) -
* Fix double parens around module constraint in functor application :
module M = F ((A : T))becomesmodule M = F (A : T). (#2678, @EmileTrotignon) -
Fix misplaced
;;due to interaction with floating doc comments.
(#2691, @EmileTrotignon) -
The formatting of attributes of expression is now aware of the attributes
infix or postix positions:((fun [@a] x -> y) [@b])is formatted without
moving attributes. (#2676, @EmileTrotignon) -
begin%e ... endandbegin [@a] ... endnodes are always preserved.
(#2676, @EmileTrotignon) -
begin endsyntax for()is now preserved. (#2676, @EmileTrotignon) -
Fix a crash on
type 'a t = A : 'a. {a: 'a} -> 'a t. (#2710, @EmileTrotignon) -
Fix a crash where
type%e nonrec t = twas formatted astype nonrec%e t = t,
which is invalid syntax. (#2712, @EmileTrotignon) -
Fix commandline parsing being quadratic in the number of arguments
(#2724, @let-def) -
* Fix
;;being added after a documentation comment (#2683, @EmileTrotignon)
This results in more;;being inserted, for example:(* before *) print_endline "foo" let a = 3 (* after *) print_endline "foo" ;; let a = 3
-
Fix dropped comment in
if then (* comment *) begin .. end(#2734, @Julow)