fantomas
fantomas copied to clipboard
Removes type annotation without brackets
Issue created from fantomas-online
Code
let clReducedValues, clFirstActualKeys, clSecondActualKeys: ClArray<'a> * ClArray<int> * ClArray<int> =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
Result
let clReducedValues, clFirstActualKeys, clSecondActualKeys =
reduce processor DeviceOnly resultLength clOffsets clFirstKeys clSecondKeys clValues
Problem description
Fantomas removes type annotation without brackets. But when brackets are placed around names, annotations are not removed.
Extra information
- [x] The formatted result breaks my code.
- [ ] The formatted result gives compiler warnings.
- [ ] I or my company would be willing to help fix this.
- [ ] I would like a release if this problem is solved.
Options
Fantomas main branch at 1/1/1990
Default Fantomas configuration
Did you know that you can ignore files when formatting by using a .fantomasignore file? PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.
Hello, thank you for your interest in this project! Tuple bindings are covered a bit differently due to historical reasons. Which is why the return type is missing.
I believe the problem is centered around: https://github.com/fsprojects/fantomas/blob/0ce91b778f216c2d7fa8286d1aa4aa5dbf835bcc/src/Fantomas.Core/CodePrinter.fs#L2866-L2867
There we could do something like:
let genDestructedTuples =
expressionFitsOnRestOfLine (genPat pat) (sepOpenT +> genPat pat +> sepCloseT)
+> optSingle
(fun (rt: BindingReturnInfoNode) ->
genSingleTextNode rt.Colon
+> sepSpace
+> atCurrentColumnIndent (genType rt.Type))
b.ReturnType
to print the return type when it is present.
I'm not sure how well this exact fix would play when the tuple is multiline. Something like
let a, //
b, //
c
: int * int * int = 1,2,3
Might be a corner case.
Are you interested in submitting a PR for this one?