Skip to content

Line comment after the opening parenthesis of a type moves and breaks the type #3559

Closed

Description

@nojaf

Issue created from fantomas-online

Code

type T = ( // c
    Map<string, int>)

Result

type T =
    (Map // c
    <string, int>)

Problem description

Fantomas found this wrong with its result:

  • The result is not valid F#
    • Fantomas cannot parse the code it produced. The diagnostics are about that code.

A line comment after the ( of a parenthesized type is written after the first type inside instead, and the rest of the type goes on the next line, at the indent. For a generic type that splits Map from <string, int>, which does not parse.

Other types inside the parentheses go wrong in other ways:

  • ( // c then int * string: the result is not idempotent, the second format moves the * to a line of its own.
  • ( // c then a -> b: valid, but the comment still moves after a, and a blank line appears under it.

A comment on the line after the (, or after the first type, is kept where it is.

Not a regression: 7.0.6, 8.0.10, main and the 9.0.0-alpha-001 preview all fail.

Found while working on #3554.

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-10-20T12:59:18Z - 79babfa

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 Dec 1, 2026
    cc175ce
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