ocamlformat
ocamlformat copied to clipboard
Bug: Unable to process a file in xen-api
Ocamlformat 0.21.0 is unable to format the file ocaml/xapi/xapi_session.ml
from the repository https://github.com/xapi-project/xen-api when formatting with the custom .ocamlformat (which contains deprecated options)
Ocamlformat prints the following message:
File "dune-project", line 3, characters 0-32:
3 | (formatting (enabled_for ocaml))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning: option `indicate-multiline-delimiters`: value `closing-on-separate-line` is deprecated since version 0.20.0. It will be removed by version 1.0.0.
Warning: option `if-then-else`: value `fit-or-vertical` is deprecated since version 0.20.0. It will be removed by version 1.0.0.
Warning: break-struct: This option is deprecated since version 0.20.0. It will be removed by version 1.0.0.
Warning: option `indicate-multiline-delimiters`: value `closing-on-separate-line` is deprecated since version 0.20.0. It will be removed by version 1.0.0.
Warning: option `if-then-else`: value `fit-or-vertical` is deprecated since version 0.20.0. It will be removed by version 1.0.0.
Warning: break-struct: This option is deprecated since version 0.20.0. It will be removed by version 1.0.0.
ocamlformat: Cannot process "ocaml/xapi/xapi_session.ml".
Please report this bug at https://github.com/ocaml-ppx/ocamlformat/issues.
BUG: formatting did not stabilize after 10 iterations.
How to Reproduce Steps to reproduce the behavior:
- Create a new switch with ocaml 4.14.0, the latest dune and ocamlformat 0.21.0
- Clone the xen-api repository
- run
dune build @fmt
Tested with ocamlformat 0.22.4: still happening:
dune build @fmt --auto-promote
File "dune-project", line 3, characters 0-32:
3 | (formatting (enabled_for ocaml))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ocamlformat: Cannot process "ocaml/xapi/xapi_session.ml".
Please report this bug at https://github.com/ocaml-ppx/ocamlformat/issues.
BUG: formatting did not stabilize after 10 iterations.
I've tried a few things but nothing that would fix this without breaking the comments in other places. Here is a minimal snippet to reproduce the bug if someone has some time to have a look:
let _ =
List.filter
(fun s ->
((* 3.1. the sid of the authenticated user *)
foooooooooooooooooooooooooooooo
|| (* 3.2. any sids of the group that authenticated the user *)
(* TODO: better to look up the membership closure *)
fooooooooooooooooooooooooooo
)
)
I'll change the weird code, but that won't change any instances where this might happen ;)