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

Elmish-like syntax using yields with interspersed let statements breaks the code #1191

Closed
2 of 3 tasks
renngar opened this issue Oct 11, 2020 · 1 comment · Fixed by #1311
Closed
2 of 3 tasks

Elmish-like syntax using yields with interspersed let statements breaks the code #1191

renngar opened this issue Oct 11, 2020 · 1 comment · Fixed by #1311

Comments

@renngar
Copy link

renngar commented Oct 11, 2020

Issue created from fantomas-online

Code

let private fn (xs: int []) =
    fn2
        ""
        [ let r = Seq.head xs

          yield r

          let s = fn2()
          s.DoSomething() ]

Error

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

let private fn (xs: int []) =
    fn2
        ""
        [ let r = Seq.head xs

        yield r

        let s = fn2 ()
        s.DoSomething() ]

Problem description

If you have an Elmish like syntax that uses yields interspersed with lets everything after the first let is not indented correctly yielding broken code.

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.

As in the other issue, I am unfamiliar with the Fantomas code, but would be willing to try with some direction.

Options

Fantomas Master at 10/02/2020 17:06:53 - 31305c2

Default Fantomas configuration

@nojaf
Copy link
Contributor

nojaf commented Oct 16, 2020

Interesting, the SynExpr.LetOrUse expression inside the list should be printed with the atCurrentColumn helper function at first glance.

To have an idea how Fantomas works you can watch some videos on YouTube.

As for this case, I would start with a failing unit test in ListTests.fs and try and find in the CodePrinter.fs where the SynExpr.LetOrUse inside the list is printed.
You can do this exploring as part of draft PR and I can guide you along the way from there if you want.

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