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

Nested if/else/then in short mode #1243

Closed
1 of 3 tasks
nojaf opened this issue Nov 12, 2020 · 0 comments · Fixed by #1249
Closed
1 of 3 tasks

Nested if/else/then in short mode #1243

nojaf opened this issue Nov 12, 2020 · 0 comments · Fixed by #1249

Comments

@nojaf
Copy link
Contributor

nojaf commented Nov 12, 2020

Issue created from fantomas-online

Code

            let funcs =
                fse.MembersFunctionsAndValues
                |> Seq.sortWith (fun n1 n2 ->
                    let modifierScore (f : FSharpMemberOrFunctionOrValue) =
                        if f.IsProperty then
                            if f.IsInstanceMember then
                                if f.IsDispatchSlot then 9 else 1
                            else 8
                        elif f.IsMember then
                            if f.IsInstanceMember then
                                if f.IsDispatchSlot then 11 else 2
                            else 10
                        else 3
                    let n1Score = modifierScore n1
                    let n2Score = modifierScore n2
                    if n1Score = n2Score then
                        n1.DisplayName.CompareTo n2.DisplayName
                    else
                        n1Score.CompareTo n2Score
                )

Error

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

let funcs =
    fse.MembersFunctionsAndValues
    |> Seq.sortWith
        (fun n1 n2 ->
            let modifierScore (f: FSharpMemberOrFunctionOrValue) =
                if f.IsProperty
                then if f.IsInstanceMember then if f.IsDispatchSlot then 9 else 1 else 8
                elif f.IsMember
                then if f.IsInstanceMember then if f.IsDispatchSlot then 11 else 2 else 10
                else 3

            let n1Score = modifierScore n1
            let n2Score = modifierScore n2
            if n1Score = n2Score then n1.DisplayName.CompareTo n2.DisplayName else n1Score.CompareTo n2Score)

Problem description

                if f.IsProperty
                then if f.IsInstanceMember then if f.IsDispatchSlot then 9 else 1 else 8

I think the short if/then syntax invalid if the if branch contains a short if/then/else.
Something along those lines.

Check out our Contribution Guidelines.

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 11/07/2020 09:02:01 - de55bd9

Default Fantomas configuration

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

Successfully merging a pull request may close this issue.

1 participant