From 9bc1ee79c02dd5ebcc1529624e482f7d084ba62e Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 31 May 2024 23:16:42 +0200 Subject: [PATCH 1/2] - add missing case AppSingleParenArg to (|UppercaseExpr|LowercaseExpr|) to fix 3088 - add tests - add CHANGELOG entry --- CHANGELOG.md | 5 +++ .../DynamicOperatorTests.fs | 34 +++++++++++++++++++ src/Fantomas.Core/CodePrinter.fs | 1 + 3 files changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f957a1d03f..28b58a5b04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [Unreleased] + +### Fixed +* Fix case determination issue with ExprAppSingleParenArgNode. [#3088](https://github.com/fsprojects/fantomas/issues/3088) + ## 6.3.5 - 2024-05-30 ### Fixed diff --git a/src/Fantomas.Core.Tests/DynamicOperatorTests.fs b/src/Fantomas.Core.Tests/DynamicOperatorTests.fs index 07df2c8d11..31c3e00b26 100644 --- a/src/Fantomas.Core.Tests/DynamicOperatorTests.fs +++ b/src/Fantomas.Core.Tests/DynamicOperatorTests.fs @@ -76,3 +76,37 @@ let ``preserve back ticks from checked keyword, 937`` () = """ let toggle = unbox (e.target?``checked``) """ + +[] +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) +""" + +[] +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") +""" diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index 658f5fcdd1..577fb821ec 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -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) = From 0094515d5a3c60cb6545253170f11b6ef8669eb7 Mon Sep 17 00:00:00 2001 From: dawe Date: Sat, 1 Jun 2024 10:11:57 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Florian Verdonck --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28b58a5b04..a8300a0011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## 6.3.6 - 2024-06-01 ### Fixed * Fix case determination issue with ExprAppSingleParenArgNode. [#3088](https://github.com/fsprojects/fantomas/issues/3088)