Skip to content

Delegates are broken up around -> which leads to illegal code #2468

Description

@abelbraaksma

Issue created from fantomas-online

Code

type some_delegate = delegate of Func<int, int> * Guid * string * Func<Func<int, int>, int> -> Func<Func<int, int>, string, string>

Result

type some_delegate = delegate of Func<int, int> * Guid * string * Func<Func<int, int>, int> ->
    Func<Func<int, int>, string, string>

Problem description

In the example here I used some nonsense delegate just to illustrate the issue. It happens whenever the delegate definition is too wide. The result is non-compilable.

As a workaround I just place these definitions (I have a bunch of them) in a separate file and ignore it. I know delegates aren't really used that much in F# anyway.

Btw, tbh, I don't really know what a "best practice" format is for delegates, but I think the easiest fix would be to simply not format them at all. Alternatively, something like this works:

type some_delegate = delegate of 
                        Func<int, int> * Guid * string * Func<Func<int, int>, int> ->
                        Func<Func<int, int>, string, string>

Another way would be this:

type some_delegate = 
    delegate of 
       Func<int, int> * Guid * string * Func<Func<int, int>, int> ->
       Func<Func<int, int>, string, string>

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings errors.
  • I or my company would be willing to help fix this. (I'm a bit busy, but I'll try!)

Options

Fantomas master branch at 2022-08-31T07:53:05Z - 0981dfe

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

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