Skip to content

Regression: Stroustrup bracket style in anonymous record type parameter is not respected #3069

Closed

Description

@cmeeren

Issue created from fantomas-online

Related: #2706

Code and expected

let private asJson (arm: IArmResource) =
    arm.JsonModel
    |> convertTo<{|
        kind: string
        properties: {| statisticsEnabled: bool |}
    |}>

Result

let private asJson (arm: IArmResource) =
    arm.JsonModel
    |> convertTo<
        {|
            kind: string
            properties: {| statisticsEnabled: bool |}
        |}
        >

Problem description

I just updated from 6.2.3 to 6.3.0. Suddenly all my anonymous record type parameters are using aligned style even though I have configured Stroustrup style.

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 2024-03-18T09:36:28Z - 74fb395

    { config with
                MultilineBracketStyle = stroustrup }

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. github-actions commented on Mar 2, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I investigated the root cause of this regression. The issue lies in two interacting parts of CodePrinter.fs.

    Root Cause

    1. colGenericTypeParameters (line ~2362) ignores MultilineBracketStyle

    When a generic type like convertTo<{| ... |}> needs to span multiple lines, colGenericTypeParameters always uses the "aligned" long form:

    let long = indentSepNlnUnindent (genParameters (sepComma +> sepNln)) +> sepNln

    This unconditionally places the type arguments on the next line with an indent, giving:

    |> convertTo<
        {|
            ...
        |}
        >

    There is no Stroustrup-aware path here — the type parameter is always indented to a new line when multiline.

    2. Type.AnonRecord long-form uses ifAlignOrStroustrupBrackets which treats Aligned and Stroustrup identically

    ifAlignOrStroustrupBrackets
        (genStruct
         +> sepOpenAnonRecdFixed
         +> indentSepNlnUnindent (atCurrentColumnIndent genAnonRecordFields)
         +> sepNln
         +> genSingleTextNode node.Closing)   // Aligned AND Stroustrup: same output
        (genStruct
         +> genOpening
         +> atCurrentColumn genAnonRecordFields
         ...
         +> genSingleTextNode node.Closing)   // Cramped

    So for MultilineBracketStyle = Stroustrup, the anonymous record type gets the same formatting as Aligned.

    What the fix would involve

    The Stroustrup expectation for a type application with an anonymous record argument would be that the {| opens on the same line as <, with fields indented and |}> closing naturally:

    |> convertTo<{|
        kind: string
        properties: {| statisticsEnabled: bool |}
    |}>

    This would require:

    • colGenericTypeParameters to detect when MultilineBracketStyle = Stroustrup and keep the first argument on the same line (instead of indentSepNlnUnindent)
    • OR the > handling in Type.AppPrefix to be Stroustrup-aware

    This is non-trivial because it touches the interaction between how generic type argument lists and anonymous record types are independently formatted. A fix would need to be carefully coordinated between Type.AppPrefix and Type.AnonRecord to avoid producing parse errors or misaligned output.

    I'm flagging this for maintainer attention — it's a genuine regression that would benefit from a targeted fix.

    Generated by Repo Assist

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@da02dddebe71d9a937665abdcd1f5214dab852a7
    
  2. added a commit that references this issue on Apr 17, 2026
    956791e
  3. added a commit that references this issue on Oct 7, 2026
    d04aece
  4. added a commit that references this issue on Oct 21, 2026
    78a0d8c
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