Skip to content

Brace on its own line for object expressions? #3469

Description

@njlr

Unsure if this is a feature request or a bug.

I would like to put the opening brace of an object expression on its own line:

let sayGoodbye =
  { 
    new IDisposable with
      member this.Dispose() =
        println "Goodbye"
  }

But in the tool it puts it on the same line as new:

let sayGoodbye =
  { new IDisposable with
      member this.Dispose() = println "Goodbye"
  }

Is the format I am looking for possible?

Issue created from fantomas-online

Code

let sayGoodbye =
  {
    new IDisposable with
      member this.Dispose() =
        println "Goodbye"
  }

Result

let sayGoodbye =
  { new IDisposable with
      member this.Dispose() = println "Goodbye"
  }

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

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-11T07:35:37Z - 4ec27ee

    { config with
                IndentSize = 2
                SpaceBeforeColon = true
                RecordMultilineFormatter = number_of_items
                ArrayOrListMultilineFormatter = number_of_items
                MultiLineLambdaClosingNewline = true
                BarBeforeDiscriminatedUnionDeclaration = true }

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions