Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: drops comments before begin with exp-grouping=preserve #2543

Open
acieroid opened this issue Apr 17, 2024 · 1 comment
Open

Bug: drops comments before begin with exp-grouping=preserve #2543

acieroid opened this issue Apr 17, 2024 · 1 comment

Comments

@acieroid
Copy link

Describe the bug
OCamlformat drops comments before a begin with exp-grouping=preserve.

How to Reproduce
Steps to reproduce the behavior:

  • What is the formatted file? Please try to minimize the code snippet.
let _ =
  match "foo" with
  | _ ->
    (* comment *)
    begin match "bar" with
      _ -> "baz"
    end
  • What are the selected options?
version=0.26.1
profile=default
exp-grouping=preserve

(--print-config output listed at the end)

Results in:

$ ocamlformat foo.ml
ocamlformat: Cannot process "foo.ml".
  Please report this bug at https://github.com/ocaml-ppx/ocamlformat/issues.
  BUG: comment changed.
File "foo.ml", line 4, characters 4-17:
Error: comment (*  comment  *) dropped.
$ ocamlformat --print-config
comment-check=true
debug=false
disable=false
margin-check=false
max-iters=10
ocaml-version=4.04.0
quiet=false
disable-conf-attrs=false
version-check=true
assignment-operator=end-line (profile default (file .ocamlformat:2))
break-before-in=fit-or-vertical (profile default (file .ocamlformat:2))
break-cases=fit (profile default (file .ocamlformat:2))
break-collection-expressions=fit-or-vertical (profile default (file .ocamlformat:2))
break-colon=after (profile default (file .ocamlformat:2))
break-fun-decl=wrap (profile default (file .ocamlformat:2))
break-fun-sig=wrap (profile default (file .ocamlformat:2))
break-infix=wrap (profile default (file .ocamlformat:2))
break-infix-before-func=false (profile default (file .ocamlformat:2))
break-separators=after (profile default (file .ocamlformat:2))
break-sequences=true (profile default (file .ocamlformat:2))
break-string-literals=auto (profile default (file .ocamlformat:2))
break-struct=force (profile default (file .ocamlformat:2))
cases-exp-indent=4 (profile default (file .ocamlformat:2))
cases-matching-exp-indent=normal (profile default (file .ocamlformat:2))
disambiguate-non-breaking-match=false (profile default (file .ocamlformat:2))
doc-comments=after-when-possible (profile default (file .ocamlformat:2))
doc-comments-padding=2 (profile default (file .ocamlformat:2))
doc-comments-tag-only=default (profile default (file .ocamlformat:2))
dock-collection-brackets=true (profile default (file .ocamlformat:2))
exp-grouping=preserve (file .ocamlformat:3)
extension-indent=2 (profile default (file .ocamlformat:2))
field-space=loose (profile default (file .ocamlformat:2))
function-indent=2 (profile default (file .ocamlformat:2))
function-indent-nested=never (profile default (file .ocamlformat:2))
if-then-else=compact (profile default (file .ocamlformat:2))
indent-after-in=0 (profile default (file .ocamlformat:2))
indicate-multiline-delimiters=no (profile default (file .ocamlformat:2))
indicate-nested-or-patterns=unsafe-no (profile default (file .ocamlformat:2))
infix-precedence=indent (profile default (file .ocamlformat:2))
leading-nested-match-parens=false (profile default (file .ocamlformat:2))
let-and=compact (profile default (file .ocamlformat:2))
let-binding-indent=2 (profile default (file .ocamlformat:2))
let-binding-spacing=compact (profile default (file .ocamlformat:2))
let-module=compact (profile default (file .ocamlformat:2))
line-endings=lf (profile default (file .ocamlformat:2))
margin=80 (profile default (file .ocamlformat:2))
match-indent=0 (profile default (file .ocamlformat:2))
match-indent-nested=never (profile default (file .ocamlformat:2))
max-indent=68 (profile default (file .ocamlformat:2))
module-item-spacing=compact (profile default (file .ocamlformat:2))
nested-match=wrap (profile default (file .ocamlformat:2))
ocp-indent-compat=false (profile default (file .ocamlformat:2))
parens-ite=false (profile default (file .ocamlformat:2))
parens-tuple=always (profile default (file .ocamlformat:2))
parens-tuple-patterns=multi-line-only (profile default (file .ocamlformat:2))
parse-docstrings=false (profile default (file .ocamlformat:2))
parse-toplevel-phrases=false (profile default (file .ocamlformat:2))
sequence-blank-line=preserve-one (profile default (file .ocamlformat:2))
sequence-style=terminator (profile default (file .ocamlformat:2))
single-case=compact (profile default (file .ocamlformat:2))
space-around-arrays=true (profile default (file .ocamlformat:2))
space-around-lists=true (profile default (file .ocamlformat:2))
space-around-records=true (profile default (file .ocamlformat:2))
space-around-variants=true (profile default (file .ocamlformat:2))
stritem-extension-indent=0 (profile default (file .ocamlformat:2))
type-decl=compact (profile default (file .ocamlformat:2))
type-decl-indent=2 (profile default (file .ocamlformat:2))
wrap-comments=false (profile default (file .ocamlformat:2))
wrap-fun-args=true (profile default (file .ocamlformat:2))
profile=default (file .ocamlformat:2)
$ ocaml --version
The OCaml toplevel, version 4.14.1
@Julow
Copy link
Collaborator

Julow commented Apr 18, 2024

Thanks for reporting! This is fixed on main. It seems to be the same as #2539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants