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

Match statements should not be split into separate lines between parentheses #2044

Closed
3 tasks
ghost opened this issue Jan 27, 2022 · 3 comments · Fixed by #2469
Closed
3 tasks

Match statements should not be split into separate lines between parentheses #2044

ghost opened this issue Jan 27, 2022 · 3 comments · Fixed by #2469
Labels
bug (stylistic) good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@ghost
Copy link

ghost commented Jan 27, 2022

Issue created from fantomas-online

Code

type Foo =
  | Bar of int
  | Baz

let foo =
  function
  | Foo (1 | 2) -> true
  | _ -> false

Result

type Foo =
    | Bar of int
    | Baz

let foo =
    function
    | Foo (1
    | 2) -> true
    | _ -> false

Problem description

When I format match expressions using multiple sub-cases in parentheses, Fantomas formats each sub-case as though it were a main case, whereas it should not split short parenthesized expressions across lines.

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas master branch at 1/1/1990

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?

@nojaf
Copy link
Contributor

nojaf commented Jan 28, 2022

Hello, thank you for reporting this issue.

The main problem here is that Fantomas has one way of formatting patterns regardless of where in the syntax tree they occur.
I believe some separation of printing patterns in CodePrinter.fs might be interesting to introduce to tackle these kinds of problems.

Are you interested in submitting a PR for this?

@ghost
Copy link
Author

ghost commented Jan 28, 2022

Are you interested in submitting a PR for this?

Unfortunately, I am not.

@nojaf
Copy link
Contributor

nojaf commented Aug 31, 2022

This was fixed by #2407.
A regression test could solve this issue.

@nojaf nojaf added the good first issue Long hanging fruit: easy issue to get your feet wet! label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (stylistic) good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant