ocamlformat icon indicating copy to clipboard operation
ocamlformat copied to clipboard

Feature request: consistent placement of comments before nested let

Open craigfe opened this issue 3 years ago • 1 comments

The following example is OCamlformatted:

;;
assert (
  (* [a] is true *)
  let a = true in
  a )

This placement of the comment before the let binding looks correct to me, but the equivalents for let module and let exception do not behave in the same way. In particular, the comments get put somewhere inside the let binding itself:

;;
assert (
  let module (* [A.v] is true *)
      A = struct
    let v = true
  end in
  A.v || b )

;;
assert (
  let exception (* [Foo] is raised *)
                  Foo in
  raise Foo )

These last two examples look broken to me. Note that the same issue doesn't happen for let-bindings not inside a function parameter:

let () =
  (* [a] is true *)
  let a = true in
  (* [A.v] is true *)
  let module A = struct
    let v = true
  end in
  (* [Foo] is raised *)
  let exception Foo in
  ()

craigfe avatar Jan 05 '21 11:01 craigfe