Skip to content

Bug: match expr with gets spread into 3 lines in 0.28.1 #2766

@psafont

Description

@psafont

Describe the bug
When a match expr with is one of the two branches of if true then ... else ... it gets formatted into 3 lines, this behaviour started in 0.28.1 and is not present under 0.27.0. I couldn't find any explanation, or PR related to this change, and it happens for very short lines, so I'm assuming it's a bug

How to Reproduce
Steps to reproduce the behavior:
Run ocamlformat 0.28.1 with the profile from https://github.com/xapi-project/xen-api/blob/57f657fd85771d901b18658c561f8a0d592f1f0b/.ocamlformat to format this file:

let name =
  if true then
    match expr with true -> () | false -> ()
  else
    match expr with true -> () | false -> ()

It produces:

let name =
  if true then
    match
      expr
    with
    | true ->
        ()
    | false ->
        ()
  else
    match
      expr
    with
    | true ->
        ()
    | false ->
        ()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions