-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
record mutation: first field after with
should be placed in a new line
#457
Comments
I've also tried to first typecheck with my language server, and send the AST to Fantomas -- the formatting result is mostly correct (see #456), but the comments are gone. |
Comments are not included in AST. |
I know. I think the first part is more interesting -- using AST does not repro the problem. |
Oh, okay, I misinterpreted it. That means problem is probably in comments. This issue is definitely elusive, I tried to find smaller repro but without success (for example whole class |
I was able to find minimized repro. |
Ok, so fix could be to auto add a newline after the |
@nojaf ideally yes. I haven’t dig into fantomas codebase yet — just wondering: why does it behave correctly in some conditions? @jindraivanek did you find patterns? That minimal repro definitely helps to simplify things. :) |
In the minimal repro, if we remove the first line (let x = .....), then the record formats correctly. |
Turning on strict mode mutes the repro — this echos the AST formatting approach. |
@yatli Yes, also |
|
ok, the reason "it doesn't repro on simpler cases": let _ =
let x = Foo(1).Bar()
x
let F x = x
type T = A | B | C of int
let r =
{ s with
x = 1
y = 2 }
// repro It infects following lines |
...and this: let r =
{ s with
x = 1
y = 2 }
let x = (fun () -> Foo(1).Bar())
let r =
{ s with
x = 1
y = 2 } ===> let r =
{ s with
x = 1
y = 2 }
let x = (fun () -> Foo(1).Bar())
let r =
{ s with x = 1
y = 2 }
|
It turns on some kind of switch? |
I found the bug, it was indeed caused by incorrectly set switch here: fantomas/src/Fantomas/Context.fs Lines 402 to 406 in 7d5d3f1
Will fix soon. |
I'm integrating fantomas into coc-fsharp with API
FormatDocumentAsync
.I'm using
3.0-beta002
nuget package.Problem example:
becomes:
online fantomas code
Note, this problem does not repro with all record mutations -- not sure about the condition, but I tried a few simpler cases and it works as expected -- this is exactly the repro snippet, extracted from the full source file given in the link above.
The text was updated successfully, but these errors were encountered: