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

Unexpected newline after inner let binding #1709

Closed
3 tasks
nojaf opened this issue May 9, 2021 · 1 comment · Fixed by #1710
Closed
3 tasks

Unexpected newline after inner let binding #1709

nojaf opened this issue May 9, 2021 · 1 comment · Fixed by #1710

Comments

@nojaf
Copy link
Contributor

nojaf commented May 9, 2021

Issue created from fantomas-online

Code

[<Fact>]
let ``first lamba`` () =
    // You can use the `fun` keyword to write lambda's.
    // Mind the -> instead of C#'s =>
    // TODO: complete the lambda so that the value is returned in uppercase.
    let toUpperCase = fun a -> a
    // ref: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword

    let name = "Joey"
    let uppercased = toUpperCase name
    Assert.Equal("JOEY", uppercased)

Result

[<Fact>]
let ``first lamba`` () =
    // You can use the `fun` keyword to write lambda's.
    // Mind the -> instead of C#'s =>
    // TODO: complete the lambda so that the value is returned in uppercase.
    let toUpperCase = fun a -> a
    // ref: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword

    let name = "Joey"

    let uppercased = toUpperCase name
    Assert.Equal("JOEY", uppercased)

Problem description

Was not expected the newline in this case.

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/08/2021 20:14:38 - 768402e

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?

@nojaf
Copy link
Contributor Author

nojaf commented May 9, 2021

Probably related:

[<Fact>]
let ``update a record`` () =
    let record = { Name = "1"; ReleaseYear = 2001 } // notice how the member can be put on a single line if you separate them with a `;`.
    // In fact the `;` in F# indicates as a newline in certain scenario's. More on that when we get to lists.

    let correctedRecord = record // TODO: update the ReleaseYear to 2000
    Assert.Equal(2000, correctedRecord.ReleaseYear)

nojaf added a commit that referenced this issue May 9, 2021
* Leading newline because of trivia does not item multiline. Fixes #1709.

* Add release notes for 4.5.0-alpha-016.
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.

1 participant