-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
tuple with match formats to invalid code #1269
Comments
Hello Tom, Thank you for reporting this issue. It appears that Fantomas joins every synExpr of a tuple with a comma and a new line (if the whole expression is multiline). So in pseudo code: let myTuple = a, b If let myTuple =
a,
b See genTuple. In the case of SynExpr.Match, this leads to different code that what you originally had. Would you be interested in submitting a pull request? |
I'll give it a try. |
Hi Florian, thank you so much for explaining the issue and pointing to the right place. I wrote some unit tests and fixed this issue, or at least I hope I fixed it 😅 . One thing I am not sure if it's important. If I have a long tuple and the match is the last element in it should it also be formatted with commas at the beginning of the line? Here two examples. This match "Hello" with
| "first" -> 1
| "second" -> 2
| _ -> 3
, 1
, "Hello" must be formatted like it is, I think, because of the semantics. But this 1
, "Hello"
, match "Hello" with
| "first" -> 1
| "second" -> 2
| _ -> 3 can be formatted like this 1,
"Hello",
match "Hello" with
| "first" -> 1
| "second" -> 2
| _ -> 3 with my current implementation it will be formatted with commas at the beginning of the line. Also, I think that maybe it is not important. One should not write code like this 😁 |
@ThisFunctionalTom Thanks for submitting the PR (and humour)! |
Issue created from fantomas-online
Code
Result
Problem description
When formatting a tuple with pattern match as first element fantomas puts comma in the wrong place and generates not compilable code.
Expected formatting:
Extra information
Options
Fantomas 4.2.0
Default Fantomas configuration
The text was updated successfully, but these errors were encountered: