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

Lazy causes indentation to produce invalid F# #1805

Closed
2 tasks
Smaug123 opened this issue Jul 2, 2021 · 2 comments · Fixed by #1808
Closed
2 tasks

Lazy causes indentation to produce invalid F# #1805

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

Comments

@Smaug123
Copy link
Contributor

Smaug123 commented Jul 2, 2021

Issue created from fantomas-online

Code

module Foo =
    let foo =
        lazy (
            if not <| bar then
                raise <| Exception "Very very very very very very very very very very very very very very long"
            let ret = false
            if ret then
                "foo"
            else
                "bar"
            |> log.Info
            ret
        )

Result

module Foo =
    let foo =
        lazy
            (if not <| bar then
                 raise
                 <| Exception "Very very very very very very very very very very very very very very long"

            let ret = false

            if ret then "foo" else "bar"
            |> log.Info

            ret)

Problem description

The let ret = false line can't go where it currently is, for indentation reasons. I think the solution in the original code snippet, of putting the bracket on the preceding line and then indenting everything one place, looks best - but possibly worth discussing with other people.

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/01/2021 18:56:12 - 3a12872

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?

@Smaug123
Copy link
Contributor Author

Smaug123 commented Jul 2, 2021

We have an easy workaround for this internally: in scope, we've already essentially got Lazy.fromFunc : (unit -> 'a) -> Lazy<'a> which we can use instead.

@nojaf
Copy link
Contributor

nojaf commented Jul 3, 2021

I'm going to solve the problem of the invalid result in this issue, but I also raised dotnet/docs#24977. So perhaps later, I can circle back if this is also a stylistic bug.

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