-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Broken comma in match expression in parameter invocation #1869
Comments
This is quite the horrible code you have there. I would advise against passing match expressions as arguments. fantomas/src/Fantomas/CodePrinter.fs Lines 916 to 950 in a80f888
so that in this case, the comma is also flipped. |
I think I also hit this issue but with function matching. Old Code module Util
open Aether
let inline non<'a when 'a : equality> (def : 'a) : Lens<'a option, 'a> =
( function
| Some(a) -> a
| None -> def
, fun a _ -> if a = def then None else Some(a)
) Note that Aether's lens is a tuple of getter and setter so are defining a tuple of functions. Result of formatting let inline non<'a when 'a: equality> (def: 'a) : Lens<'a option, 'a> =
(function
| Some (a) -> a
| None -> def, (fun a _ -> if a = def then None else Some(a))) With the formatting, the F# compiler complains I worked around it by putting parens around the getter function, so fantomas formats it to let inline non<'a when 'a: equality> (def: 'a) : Lens<'a option, 'a> =
((function
| Some (a) -> a
| None -> def),
(fun a _ -> if a = def then None else Some(a))) Which compiles but is still somewhat confusing to read since you don't instantly notice the comma |
I believe this issue is fixed. |
Issue created from fantomas-online
Code
Result
Problem description
When using a match expression as a parameter argument, the comma that separates parameters can be misinterpreted by the F# compiler as a tuple separator.
Options for disambiguating include:
Extra information
Options
Fantomas Master at 08/11/2021 17:06:14 - 383b729
Default Fantomas configuration
Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?
The text was updated successfully, but these errors were encountered: