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

Fix exn in (|UppercaseExpr|LowercaseExpr|) #3091

Merged
merged 2 commits into from
Jun 1, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.3.6 - 2024-06-01

### Fixed
* Fix case determination issue with ExprAppSingleParenArgNode. [#3088](https://github.com/fsprojects/fantomas/issues/3088)

## 6.3.5 - 2024-05-30

### Fixed
Expand Down
34 changes: 34 additions & 0 deletions src/Fantomas.Core.Tests/DynamicOperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,37 @@ let ``preserve back ticks from checked keyword, 937`` () =
"""
let toggle = unbox<bool> (e.target?``checked``)
"""

[<Test>]
let ``case determination issue with ExprAppSingleParenArgNode, 3088`` () =
formatSourceString
"""
let doc = x?a("")?b(t)?b(t)
"""
config
|> prepend newline
|> should
equal
"""
let doc = x?a ("")?b (t)?b (t)
"""

[<Test>]
let ``case determination issue with ExprAppSingleParenArgNode uppercase with config lower, 3088`` () =
// We want to disobey SpaceBefore(Upper|Lower)caseInvocation inside of the ? chain because mixing it up can generate invalid code like x?a("arg")?B ("barg")?c("carg")
// The space config that is used (Upper or Lower) depends on the case of the dynamic object, here x
formatSourceString
"""
let doc1 = x?a("arg")?B("barg")?c("carg")
let doc2 = X?a("arg")?B("barg")?c("carg")
"""
{ config with
SpaceBeforeLowercaseInvocation = false
SpaceBeforeUppercaseInvocation = true }
|> prepend newline
|> should
equal
"""
let doc1 = x?a("arg")?B("barg")?c("carg")
let doc2 = X?a ("arg")?B ("barg")?c ("carg")
"""
1 change: 1 addition & 0 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ let rec (|UppercaseExpr|LowercaseExpr|) (expr: Expr) =
| Expr.DotIndexedGet node -> (|UppercaseExpr|LowercaseExpr|) node.ObjectExpr
| Expr.TypeApp node -> (|UppercaseExpr|LowercaseExpr|) node.Identifier
| Expr.Dynamic node -> (|UppercaseExpr|LowercaseExpr|) node.FuncExpr
| Expr.AppSingleParenArg node -> (|UppercaseExpr|LowercaseExpr|) node.FunctionExpr
| _ -> failwithf "cannot determine if Expr %A is uppercase or lowercase" expr

let (|ParenExpr|_|) (e: Expr) =
Expand Down
Loading