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

Offside error after formatting with MultiLineLambdaClosingNewline #1741

Closed
2 tasks
Smaug123 opened this issue May 21, 2021 · 0 comments · Fixed by #1742
Closed
2 tasks

Offside error after formatting with MultiLineLambdaClosingNewline #1741

Smaug123 opened this issue May 21, 2021 · 0 comments · Fixed by #1742

Comments

@Smaug123
Copy link
Contributor

Issue created from fantomas-online

Code

module Foo =

    let bar () =
        []
        |> Seq.iter(fun (a, b) ->
            let blah =
                fieldInfos
                |> Seq.groupBy (fun fi -> fi.Name)
                |> Seq.filter (fst >> foo >> not)
                |> Seq.choose (fun (name, fieldInfos) ->
                    let fieldTypes = fieldInfos |> Seq.map (fun fi -> TypeId fi.TypeInfo.Id) |> Seq.distinct |> Seq.toList
                    match fieldTypes with
                    | [ fieldType ] -> // hi!
                        let parents = fieldInfos |> Seq.cache
                        Some (name, fieldType, parents)
                    | _ -> // differing
                        None
                )
            ()
        )

Result

module Foo =

    let bar () =
        []
        |> Seq.iter (fun (a, b) -> let blah =
                fieldInfos
                |> Seq.groupBy (fun fi -> fi.Name)
                |> Seq.filter (fst >> foo >> not)
                |> Seq.choose (fun (name, fieldInfos) -> let fieldTypes =
                        fieldInfos
                        |> Seq.map (fun fi -> TypeId fi.TypeInfo.Id)
                        |> Seq.distinct
                        |> Seq.toList

                    match fieldTypes with
                    | [ fieldType ] -> // hi!
                        let parents = fieldInfos |> Seq.cache
                        Some(name, fieldType, parents)
                    | _ -> // differing
                        None
                )

            ()
        )

Problem description

This has a bunch of offside errors due to the let migrating up one line. The error arises when enabling MultiLineLambdaClosingNewline, but not otherwise.

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 05/21/2021 11:35:53 - acd47bd

    { config with
                MultiLineLambdaClosingNewline = 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 added a commit to nojaf/fantomas that referenced this issue May 22, 2021
nojaf added a commit to nojaf/fantomas that referenced this issue May 22, 2021
nojaf added a commit that referenced this issue May 22, 2021
…in MultiLineLambdaClosingNewline setting. Fixes #1741. (#1742)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants