Skip to content

Commit

Permalink
Excluded ExprAppWithLambdaNode in Chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jan 10, 2023
1 parent b1a6e25 commit 2df4178
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Fantomas.Core.Tests/LambdaTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,3 +1497,29 @@ let _ =
b\" )
|> List.length
"

[<Test>]
let ``lambda with generic argument in function identifier, 2699`` () =
formatSourceString
false
"""
MailboxProcessor<string>.Start
(fun inbox ->
async {
while true do
let! msg = inbox.Receive()
do! sw.WriteLineAsync(msg) |> Async.AwaitTask
})
"""
config
|> prepend newline
|> should
equal
"""
MailboxProcessor<string>.Start(fun inbox ->
async {
while true do
let! msg = inbox.Receive()
do! sw.WriteLineAsync(msg) |> Async.AwaitTask
})
"""
7 changes: 7 additions & 0 deletions src/Fantomas.Core/ASTTransformer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,13 @@ let (|ChainExpr|_|) (e: SynExpr) : LinkExpr list option =
| other -> continuation [ LinkExpr.Expr other ]

match e with
// An identifier only application with a parenthesis lambda expression.
// ex: `List.map (fun n -> n)` or `MailboxProcessor<string>.Start (fun n -> n)
// Because the identifier is not complex we don't consider it a chain.
| SynExpr.App(
isInfix = false
funcExpr = SynExpr.LongIdent _ | SynExpr.Ident _ | SynExpr.DotGet(expr = SynExpr.TypeApp(expr = SynExpr.Ident _))
argExpr = ParenExpr(_, SynExpr.Lambda _, _, _)) -> None
| SynExpr.App(
isInfix = false
funcExpr = SynExpr.DotGet _ | SynExpr.TypeApp(expr = SynExpr.DotGet _)
Expand Down

0 comments on commit 2df4178

Please sign in to comment.