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

Respect the order of keyword in a letbinding #1251

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Fantomas.Tests/LetBindingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,3 +1161,26 @@ printfn "%s" (lookupMonth 12)
printfn "%s" (lookupMonth 1)
printfn "%s" (lookupMonth 13) // Throws an exception!
"""

[<Test>]
let ``print inline before private, 1250`` () =
formatSourceString false """
let inline private isIdentifier t = t.CharClass = FSharpTokenCharKind.Identifier
let inline private isOperator t = t.CharClass = FSharpTokenCharKind.Operator
let inline private isKeyword t = t.ColorClass = FSharpTokenColorKind.Keyword
let inline private isPunctuation t = t.ColorClass = FSharpTokenColorKind.Punctuation
""" config
|> prepend newline
|> should equal """
let inline private isIdentifier t =
t.CharClass = FSharpTokenCharKind.Identifier

let inline private isOperator t =
t.CharClass = FSharpTokenCharKind.Operator

let inline private isKeyword t =
t.ColorClass = FSharpTokenColorKind.Keyword

let inline private isPunctuation t =
t.ColorClass = FSharpTokenColorKind.Punctuation
"""
4 changes: 2 additions & 2 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4352,9 +4352,9 @@ and getLetBindingFunction (astContext: ASTContext)
else (!-pref +> genOnelinerAttributes astContext ats)

let afterLetKeyword =
opt sepSpace ao genAccess
+> ifElse isMutable (!- "mutable ") sepNone
ifElse isMutable (!- "mutable ") sepNone
+> ifElse isInline (!- "inline ") sepNone
+> opt sepSpace ao genAccess

let genFunctionName =
getIndentBetweenTicksFromSynPat patRange functionName
Expand Down