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

Mutually recursive functions break with function invocation above definition #1628

Closed
1 of 3 tasks
arnarthor opened this issue Apr 9, 2021 · 1 comment · Fixed by #1630
Closed
1 of 3 tasks

Mutually recursive functions break with function invocation above definition #1628

arnarthor opened this issue Apr 9, 2021 · 1 comment · Fixed by #1630

Comments

@arnarthor
Copy link

arnarthor commented Apr 9, 2021

Issue created from fantomas-online

Code

let foobar () =
    Console.WriteLine("Hello")

    let rec foo () = bar "Hello"
    and bar str = printf "%s" str |> ignore

    foo ()

let foobar () =
    let rec foo () = bar "Hello"
    and bar str = printf "%s" str |> ignore

    foo ()

Result

let foobar () =
    Console.WriteLine("Hello")

    let rec foo () = bar "Hello"
    let rec bar str = printf "%s" str |> ignore

    foo ()

let foobar () =
    let rec foo () = bar "Hello"
    and bar str = printf "%s" str |> ignore

    foo ()

Problem description

Creating mutually recursive functions within another function that has Console.WriteLine above the recursion breaks the let ... and ... syntax. Some goes for other functions, ex.

Code

let foobar () =
    SomeModule.SomeFunction("Hello")

    let rec foo () = bar "Hello"
    and bar str = printf "%s" str |> ignore

    foo ()

Result

let foobar () =
    SomeModule.SomeFunction("Hello")

    let rec foo () = bar "Hello"
    let rec bar str = printf "%s" str |> ignore

    foo ()

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 04/09/2021 08:14:41 - 8b0920d

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?

@arnarthor arnarthor changed the title Mutually recursive functions break with Console.WriteLine in scope Mutually recursive functions break with side effecting function in scope Apr 9, 2021
@arnarthor arnarthor changed the title Mutually recursive functions break with side effecting function in scope Mutually recursive functions break with function invocation above definition Apr 9, 2021
@nojaf
Copy link
Contributor

nojaf commented Apr 10, 2021

Hello Arnar, thank you for reporting this issue.
This was a regression that slipped in the 4.x release 😅, so I'm glad you brought this up.

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