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

add missing construction of return info node for deconstructed tuples #3093

Merged
merged 1 commit into from
Jun 3, 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

## [Unreleased]

### Fixed
* Fix loss of tuple type annotation without parens. [#2942](https://github.com/fsprojects/fantomas/issues/2942)

## 6.3.7 - 2024-06-01

### Fixed
Expand Down
36 changes: 36 additions & 0 deletions src/Fantomas.Core.Tests/TupleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,39 @@ a |> fun b -> if b then 0 else 1
"""
a |> (fun b -> if b then 0 else 1), 2
"""

[<Test>]
let ``removes type annotation without parens, 2942`` () =
formatSourceString
"""
let clReducedValues, clFirstActualKeys, clSecondActualKeys: ClArray<'a> * ClArray<int> * ClArray<int> =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
"""
config
|> prepend newline
|> should
equal
"""
let clReducedValues, clFirstActualKeys, clSecondActualKeys: ClArray<'a> * ClArray<int> * ClArray<int> =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
"""

[<Test>]
let ``removes type annotation without parens multiline, 2942`` () =
formatSourceString
"""
let clReducedValues, // some comment 1
clFirstActualKeys, // some comment 2
clSecondActualKeys: ClArray<'a> * ClArray<int> * ClArray<int> =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
"""
config
|> prepend newline
|> should
equal
"""
let (clReducedValues, // some comment 1
clFirstActualKeys, // some comment 2
clSecondActualKeys): ClArray<'a> * ClArray<int> * ClArray<int> =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
"""
6 changes: 6 additions & 0 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2986,6 +2986,12 @@ let genBinding (b: BindingNode) (ctx: Context) : Context =

let genDestructedTuples =
expressionFitsOnRestOfLine (genPat pat) (sepOpenT +> genPat pat +> sepCloseT)
+> optSingle
(fun (rt: BindingReturnInfoNode) ->
genSingleTextNode rt.Colon
+> sepSpace
+> atCurrentColumnIndent (genType rt.Type))
b.ReturnType

genXml b.XmlDoc
+> genAttrAndPref
Expand Down
Loading