ocamlformat
ocamlformat copied to clipboard
Bug: comments on record fields reordered
Describe the bug Some comments in record fields are misplaced and reordered relative to each other.
How to Reproduce
Given the input file:
type t =
{ a : int
; (* first comment for float fields *)
(* second comment for float fields *)
(* comment about b *)
b : float
; (* comment about c *)
c : float
}
Formatting this file in 0.19.0 gives:
type t =
{ a : int (* second comment for float fields *)
; (* first comment for float fields *)
(* comment about b *)
b : float
; (* comment about c *)
c : float
}
The second comment for float fields
comment has moved before the semicolon separating fields, and also now comes before first comment for float fields
.
Options:
--enable-outside-detected-project
--profile=janestreet
--disable-conf-files
FYI, this doesn't appear to happen with semicolon separated lists:
let x =
[ a
; (* first comment *)
(* second comment *)
(* comment about b *)
b
; (* comment about c *)
c
]
is formatted as-is.
I had a look at this one, the issue is that the "easy fix" that would fix this one would introduce regressions in a lot of places because the comment placement code is very fragile. I am still working my way up to improving the comments situation by improving the ast.