Skip to content

Fantomas inserts space that breaks index lookups (without a dot) #2519

Closed

Description

@dbrattli

Issue created from fantomas-online

Code

let test (negotiationRules: IDictionary<string, unit -> unit -> unit>) =
    let mimeType = "foo"
    negotiationRules[ mimeType ] () ()

Result

let test (negotiationRules: IDictionary<string, unit -> unit -> unit>) =
    let mimeType = "foo"
    negotiationRules [ mimeType ] () ()

Problem description

Fantomas inserts extra space between i.e negotiationRules and the [...] which breaks the code. This seems to happen if there are more than one argument after e.g negotiationRules [ mimeType ] () will be formatted correctly whiles negotiationRules [ mimeType ] () () will not.

The example is a simplified version of: https://github.com/dbrattli/Fable.Giraffe/blob/main/src/Negotiation.fs#L131

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.

Options

Fantomas master branch at 2022-09-17T05:39:07Z - c1a99d4

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

Activity

  1. nojaf commented on Sep 19, 2022

    @nojaf
    Contributor

    Hello, this is a tricky one to fix I think.
    Interestingly enough, the problem doesn't occur when one of the arguments is indexed. (sample).

    As a workaround you can use the dot notation negotiationRules.[mimeType] () () or submit a PR to fix this.

  2. github-actions commented on Mar 14, 2026

    @github-actions
  3. nojaf commented on Mar 16, 2026

    @nojaf
    Contributor

    /repo-assist which PR fixed this? We can close this as duplicate of another issue.

  4. github-actions commented on Mar 16, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    This was fixed by PR #3259 ("Fix index-without-dot followed by application arguments"), merged on 2026-03-09 and included in 8.0.0-alpha-005.

    The root cause described in that PR matches exactly: the App active pattern was flattening through IndexWithoutDot expressions and losing the no-space semantics, causing expr[idx] () () to become expr [ idx ] () () when multiple arguments followed the indexer.

    Happy to close this as resolved by that PR!

    Generated by Repo Assist for issue #2519 · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f
    
  5. nojaf commented on Mar 16, 2026

    @nojaf
    Contributor

    /repo-assist okay, add another regression test for this specific report. Include in changelog but in unreleased section (even if that is technically not 100% accurate)

  6. added a commit that references this issue on Mar 24, 2026
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