Skip to content

Commit

Permalink
Merge pull request fsprojects#3091 from dawedawe/fix_3088
Browse files Browse the repository at this point in the history
Fix exn in (|UppercaseExpr|LowercaseExpr|)
  • Loading branch information
dawedawe committed Jun 1, 2024
2 parents cb7a8e0 + 0094515 commit 9925f66
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
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

0 comments on commit 9925f66

Please sign in to comment.