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

Multiline if expression with multiline infix operations #1775

Closed
1 of 3 tasks
nojaf opened this issue Jun 12, 2021 · 2 comments
Closed
1 of 3 tasks

Multiline if expression with multiline infix operations #1775

nojaf opened this issue Jun 12, 2021 · 2 comments
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@nojaf
Copy link
Contributor

nojaf commented Jun 12, 2021

Issue created from fantomas-online

Code

            if hasClassAttr && not (match k with SynTypeDefnKind.Class -> true | _ -> false) || 
               hasMeasureAttr && not (match k with SynTypeDefnKind.Class | SynTypeDefnKind.Abbrev | SynTypeDefnKind.Opaque -> true | _ -> false) || 
               hasInterfaceAttr && not (match k with SynTypeDefnKind.Interface -> true | _ -> false) || 
               hasStructAttr && not (match k with SynTypeDefnKind.Struct | SynTypeDefnKind.Record | SynTypeDefnKind.Union -> true | _ -> false) then 
                error(Error(FSComp.SR.tcKindOfTypeSpecifiedDoesNotMatchDefinition(), m))
            k

Result

if hasClassAttr
   && not (
       match k with
       | SynTypeDefnKind.Class -> true
       | _ -> false
   )
   || hasMeasureAttr
      && not (
          match k with
          | SynTypeDefnKind.Class
          | SynTypeDefnKind.Abbrev
          | SynTypeDefnKind.Opaque -> true
          | _ -> false
      )
   || hasInterfaceAttr
      && not (
          match k with
          | SynTypeDefnKind.Interface -> true
          | _ -> false
      )
   || hasStructAttr
      && not (
          match k with
          | SynTypeDefnKind.Struct
          | SynTypeDefnKind.Record
          | SynTypeDefnKind.Union -> true
          | _ -> false
      ) then
    error (Error(FSComp.SR.tcKindOfTypeSpecifiedDoesNotMatchDefinition (), m))

k

Problem description

The not ( ) should be formatted differently to avoid the warnings.

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 at 06/09/2021 15:42:35 - a79ebea

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 nojaf changed the title Mutliline if expression with multiline infix operations Multiline if expression with multiline infix operations Jun 17, 2021
@chausner
Copy link

Encountered a similar case in my code base:

let someFunction _ = 0
let someLongVariable = []

if not (someLongVariable |> List.contains (someFunction xy)) then
    ()

gets formatted to

let someFunction _ = 0
let someLongVariable = []

if
    not
        (
            someLongVariable
            |> List.contains (someFunction xy)
        )
then
    ()

@nojaf nojaf added the good first issue Long hanging fruit: easy issue to get your feet wet! label Jul 8, 2022
@nojaf
Copy link
Contributor Author

nojaf commented Jul 8, 2022

This problem doesn't occur anymore after #2334.
We can close this after adding a regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

No branches or pull requests

2 participants