Skip to content

Second block comment on a line is lost and the next expression moves onto the comment line #3487

Closed

Description

@nojaf

Issue created from fantomas-online

Code

a
(* b *) (* c *)
match x with
| _ -> ()

Result

a
(* b *) match x with
        | _ -> ()

Problem description

When a line holds two block comments and nothing else, the second one is dropped and the next expression is moved up onto the line of the first. With a match (or an if) that is no longer valid code; with a plain expression the comment is silently lost:

a
(* b *) (* c *)
b

becomes

a
(* b *) b

One block comment on the line, or a line comment followed by a block comment on the next line, format fine.

Same in 6.3.16, 7.0.3 and 8.0.2. Found in src/Compiler/AbstractIL/ilwrite.fs of dotnet/fsharp.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2026-09-22T13:02:48Z - 588898c

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Activity

  1. added a commit that references this issue on Sep 23, 2026
    4e361a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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