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

Long line breaks match #1403

Closed
1 of 3 tasks
Smaug123 opened this issue Jan 27, 2021 · 3 comments · Fixed by #1454
Closed
1 of 3 tasks

Long line breaks match #1403

Smaug123 opened this issue Jan 27, 2021 · 3 comments · Fixed by #1454

Comments

@Smaug123
Copy link
Contributor

Issue created from fantomas-online

Code

let foo () =
    match b.TryGetValue (longlonglonglonglong, b) with
    | true, i -> Some i
    | false, _ -> failwith ""

Result

let foo () =
    match b.TryGetValue (
              longlonglonglonglong,
              b
          ) with
    | true, i -> Some i
    | false, _ -> failwith ""

Problem description

This is very likely related to #1402.

The long line split has broken an offside rule in the match statement on the long variable name. I think if necessary, the answer if we can't fix F# might be:

let foo () =
    match
        b.TryGetValue
            (
                  longlonglonglonglong,
                  b
            )
        with
    | true, i -> Some i
    | false, _ -> failwith ""

i.e. one level of indentation on the bracket.

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 01/27/2021 07:36:19 - 138146e

    { config with
                MaxLineLength = 40
                SpaceBeforeUppercaseInvocation = true }

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@Smaug123 Smaug123 changed the title <Insert meaningful title> Long line breaks match Jan 27, 2021
@nojaf
Copy link
Contributor

nojaf commented Feb 5, 2021

Does this really break the code or just produce a warning?
The following code produces a warning for example.

open System
let b ="True"
let foo () =
    match Boolean.TryParse (
            b
          ) with
    | true, i -> Some i
    | false, _ -> failwith ""
foo()

@nojaf
Copy link
Contributor

nojaf commented Feb 5, 2021

Related compiler issue: dotnet/fsharp#10929

@Smaug123
Copy link
Contributor Author

Smaug123 commented Feb 7, 2021

If you have warnings-as-errors for FS0058 turned on, then presumably it breaks the code ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants