Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting list results in code that doesn't compile #2201

Closed
1 of 2 tasks
knocte opened this issue Apr 15, 2022 · 3 comments
Closed
1 of 2 tasks

Splitting list results in code that doesn't compile #2201

knocte opened this issue Apr 15, 2022 · 3 comments

Comments

@knocte
Copy link
Contributor

knocte commented Apr 15, 2022

Issue created from fantomas-online

Code

namespace NS

module Foo =
    let Bar() =
        [|1|]
type HopPayloadTLV =
    | OutgoingCLTV of int
    | ShortChannelId of int
    member __.ToGenericTLV() =
        let _ = Array.concat[ Foo.Bar(); Foo.Bar() ]
        ()

Result

namespace NS

module Foo =
    let Bar () = [| 1 |]

type HopPayloadTLV =
    | OutgoingCLTV of int
    | ShortChannelId of int
    member __.ToGenericTLV() =
        let _ =
            Array.concat[Foo.Bar()
            Foo.Bar()]

        ()

Problem description

It doesn't compile anymore; gives: Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • [maybe] I or my company would be willing to help fix this.

Options

Fantomas master branch at 2022-04-12T06:26:27Z - 7b35c89

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?

@nojaf
Copy link
Contributor

nojaf commented Apr 15, 2022

Duplicate of #2158
Add a space after Array.concat to avoid the new indexer expression.

@abelbraaksma
Copy link
Member

abelbraaksma commented May 10, 2022

@nojaf, unfortunately, adding a space can break code. Consider this:

Working code that fails to format for the same reasons

configureCorsPolicy
    readOnlyDict[$"{hdrKey}:0", "X-MessageID"
                 $"{hdrKey}:1", "Authorization"]

Adding space to prevent the list items to break

This code does not compile anymore, as the compiler thinks the function configureCorsPolicy now has two arguments:

configureCorsPolicy
    readOnlyDict [$"{hdrKey}:0", "X-MessageID"
                  $"{hdrKey}:1", "Authorization"]

This is similar to f dict[a; b] (f has one arg) and f dict [a;b] (f has two args) not being the same.

@nojaf
Copy link
Contributor

nojaf commented Aug 24, 2022

Fixed by #2446

@nojaf nojaf closed this as completed Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants