fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
772 stars 194 forks source link

Mishandling of comment #247

Closed SteveGilham closed 5 years ago

SteveGilham commented 6 years ago

Applying fantomas 2.7.1 to https://github.com/SteveGilham/altcover/blob/f1aa1e0a4a80a62abd5c07adf8f337fd0da025c6/AltCover/Runner.fs, the comment on line 638 ends up in a completely different part of the code (what was line 484), causing a build break, like this

                       match x.// And tidy up after everything's done
                               Name with
jindraivanek commented 6 years ago

This is comments integrate bug.

There is also wrongly placed comment before that one:

                interleave
                |> Seq.fold (fun (bev, // mocking points
                                       sq : XmlElement) x -> 
                       match x.// And tidy up after everything's done
                               Name with

Something in formatted code at this point or before it put comment integrate alg out of sync.

kellerd commented 6 years ago

Another reproduction: requires an identifier and negative counting range initialization

Code:

let test n = [ n..-1..1 ]
let y = ()
// Some comments

Becomes:

let test n = [ n.// Some Comments
                 .-1..1 ]
let y = ()
nojaf commented 5 years ago

Could not reproduce anymore online.

Please re-open if still a problem.