- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 202
Closed
Labels
Description
Hi.
I ran into some issue while formatting one of my programs. Below are details:
Issue created from fantomas-online
Code
try
    try
        ()
#if FOO
        ()
#endif
    with
    | _ -> ()
with 
| _ -> ()
Error
System.Exception: Fantomas is trying to format the input multiple times due to the detect of multiple defines.
There is a problem with merging all the code back together.
[FOO] has 4 fragments
[] has 5 fragments
Please raise an issue at https://fsprojects.github.io/fantomas-tools/#/fantomas/preview.
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\a\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439
   at Fantomas.CodeFormatterImpl.format@416-3.Invoke(FSharpList`1 _arg2) in /app/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 438
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 464
   at Fantomas.Async.map@173-2.Invoke(AsyncActivation`1 ctxt) in /app/.deps/fantomas/src/Fantomas/Utils.fs:line 173
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
--- End of stack trace from previous location ---
   at FantomasOnline.Server.Shared.Http.formatResponse@95-6.Invoke(Unit unitVar0) in /app/src/server/FantomasOnline.Shared/Http.fs:line 95
   at Ply.TplPrimitives.AwaitableContinuation`3.Invoke(Unit r)Problem description
Fantomas is unable to format valid F# (.net 6.0) program. I was able to reduce the case to the pasted code. I tried to reduce it even more but I was not able to find smaller code.
Extra information
The used program compile just fine with F# compiler so I think the issue is in Fantomas tool.
Options
Fantomas 4.6 branch at 11/10/2021 15:04:59 - 8d864c3
Default Fantomas configuration