-
Notifications
You must be signed in to change notification settings - Fork 217
Bug: Invalid syntax with monadic binds in sub-expressions #953
Copy link
Copy link
Closed
Labels
Description
Using the new monadic bind syntax within a sub-expression (an argument to a function, operator on a binop, etc...) produces a term without parenthesis, resulting in invalid syntax.
How to Reproduce
Given the input file example.ml:
let () = f (let+ x = 0 in 0)Running dune exec src/ocamlformat.exe -- -g example.ml on current master (8c06ec4) will error with "Cannot process "example.ml", generating invalid ocaml syntax". The formatted file is as follows:
let () =
f
let+ x = 0 in
0The config should be the same as ocamlformat's, but just in case:
profile=ocamlformat (file .ocamlformat:1)
quiet=false (profile ocamlformat (file .ocamlformat:1))
max-iters=10 (profile ocamlformat (file .ocamlformat:1))
comment-check=true (profile ocamlformat (file .ocamlformat:1))
wrap-fun-args=true (profile ocamlformat (file .ocamlformat:1))
wrap-comments=true (file .ocamlformat:5)
type-decl-indent=2 (profile ocamlformat (file .ocamlformat:1))
type-decl=compact (profile ocamlformat (file .ocamlformat:1))
stritem-extension-indent=0 (profile ocamlformat (file .ocamlformat:1))
space-around-variants=false (profile ocamlformat (file .ocamlformat:1))
space-around-records=false (profile ocamlformat (file .ocamlformat:1))
space-around-lists=false (profile ocamlformat (file .ocamlformat:1))
space-around-arrays=false (profile ocamlformat (file .ocamlformat:1))
single-case=compact (profile ocamlformat (file .ocamlformat:1))
sequence-style=separator (profile ocamlformat (file .ocamlformat:1))
sequence-blank-line=compact (profile ocamlformat (file .ocamlformat:1))
parse-docstrings=true (file .ocamlformat:4)
parens-tuple-patterns=multi-line-only (profile ocamlformat (file .ocamlformat:1))
parens-tuple=always (profile ocamlformat (file .ocamlformat:1))
parens-ite=false (profile ocamlformat (file .ocamlformat:1))
ocp-indent-compat=false (profile ocamlformat (file .ocamlformat:1))
nested-match=wrap (profile ocamlformat (file .ocamlformat:1))
module-item-spacing=sparse (profile ocamlformat (file .ocamlformat:1))
max-indent=none (profile ocamlformat (file .ocamlformat:1))
match-indent-nested=never (profile ocamlformat (file .ocamlformat:1))
match-indent=0 (profile ocamlformat (file .ocamlformat:1))
margin=77 (file .ocamlformat:3)
let-open=preserve (profile ocamlformat (file .ocamlformat:1))
let-module=compact (profile ocamlformat (file .ocamlformat:1))
let-binding-spacing=compact (profile ocamlformat (file .ocamlformat:1))
let-binding-indent=2 (profile ocamlformat (file .ocamlformat:1))
let-and=compact (profile ocamlformat (file .ocamlformat:1))
leading-nested-match-parens=false (profile ocamlformat (file .ocamlformat:1))
infix-precedence=indent (profile ocamlformat (file .ocamlformat:1))
indicate-nested-or-patterns=space (profile ocamlformat (file .ocamlformat:1))
indicate-multiline-delimiters=space (profile ocamlformat (file .ocamlformat:1))
indent-after-in=0 (profile ocamlformat (file .ocamlformat:1))
if-then-else=compact (profile ocamlformat (file .ocamlformat:1))
function-indent-nested=never (profile ocamlformat (file .ocamlformat:1))
function-indent=2 (profile ocamlformat (file .ocamlformat:1))
field-space=tight (profile ocamlformat (file .ocamlformat:1))
extension-sugar=preserve (profile ocamlformat (file .ocamlformat:1))
extension-indent=2 (profile ocamlformat (file .ocamlformat:1))
exp-grouping=parens (profile ocamlformat (file .ocamlformat:1))
escape-strings=preserve (profile ocamlformat (file .ocamlformat:1))
escape-chars=preserve (profile ocamlformat (file .ocamlformat:1))
doc-comments-tag-only=default (profile ocamlformat (file .ocamlformat:1))
doc-comments-padding=2 (profile ocamlformat (file .ocamlformat:1))
doc-comments=after (profile ocamlformat (file .ocamlformat:1))
disambiguate-non-breaking-match=false (profile ocamlformat (file .ocamlformat:1))
disable=false (profile ocamlformat (file .ocamlformat:1))
cases-matching-exp-indent=compact (profile ocamlformat (file .ocamlformat:1))
cases-exp-indent=4 (profile ocamlformat (file .ocamlformat:1))
break-struct=force (profile ocamlformat (file .ocamlformat:1))
break-string-literals=newlines-and-wrap (profile ocamlformat (file .ocamlformat:1))
break-sequences=false (profile ocamlformat (file .ocamlformat:1))
break-separators=before (profile ocamlformat (file .ocamlformat:1))
break-infix-before-func=true (profile ocamlformat (file .ocamlformat:1))
break-infix=wrap (profile ocamlformat (file .ocamlformat:1))
break-fun-sig=wrap (profile ocamlformat (file .ocamlformat:1))
break-fun-decl=wrap (profile ocamlformat (file .ocamlformat:1))
break-collection-expressions=fit-or-vertical (profile ocamlformat (file .ocamlformat:1))
break-cases=fit (file .ocamlformat:2)
break-before-in=fit-or-vertical (profile ocamlformat (file .ocamlformat:1))
assignment-operator=end-line (profile ocamlformat (file .ocamlformat:1))
align-variants-decl=false (profile ocamlformat (file .ocamlformat:1))
align-constructors-decl=false (profile ocamlformat (file .ocamlformat:1))
align-cases=false (profile ocamlformat (file .ocamlformat:1))
Reactions are currently unavailable