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

KeepIndentInBranch not respected inside a let and match #1825

Closed
3 tasks
Smaug123 opened this issue Jul 10, 2021 · 2 comments · Fixed by #2342
Closed
3 tasks

KeepIndentInBranch not respected inside a let and match #1825

Smaug123 opened this issue Jul 10, 2021 · 2 comments · Fixed by #2342

Comments

@Smaug123
Copy link
Contributor

Issue created from fantomas-online

Code

module Foo =

    let blah =
        
        let a =
            match true with
            | false ->
                match result with
                | Error _ -> failwith ""
                | Ok _ ->
                printfn "hi"
                failwith "blah blah blah blah"
            | true -> failwith ""

        failwith ""

Result

module Foo =

    let blah =

        let a =
            match true with
            | false ->
                match result with
                | Error _ -> failwith ""
                | Ok _ ->
                    printfn "hi"
                    failwith "blah blah blah blah"
            | true -> failwith ""

        failwith ""

Problem description

I've seen an analogue of this case appear or disappear depending on whether let a = is let a, b = or just let a =. However, for this particular reproduction, it turns out not to matter. I expected the printfn to be unindented one scope from where Fantomas put it.

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 07/07/2021 07:46:28 - 6f0df78

    { config with
                MultilineBlockBracketsOnSameColumn = true
                KeepIndentInBranch = true }

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 Jul 13, 2021

It does work if you flip the | true -> failwith "" on top, see example.
As I understood it so far, only the last branch or clause will do keep indent stuff.
Any reason the short clause is not the last one here?

@Smaug123
Copy link
Contributor Author

Ah, I see. I've forgotten the context I actually had in mind when I raised this, but it is very possible you're right and I was just being over-eager. I'll see if I can find why I raised this.

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