Splitting list results in code that doesn't compile
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
- [x] 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 - 7b35c8912c8a039bc443705019c7f15f5e6614c1
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?
Duplicate of https://github.com/fsprojects/fantomas/issues/2158
Add a space after Array.concat to avoid the new indexer expression.
@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.
Fixed by https://github.com/fsprojects/fantomas/pull/2446