Skip to content

Crash when using --keepNewlineAfter #513

Closed
@knocte

Description

Description

I've tried to run fantomas 3.0 in a project inside my solution, and it crashed with:

$ fantomas . --recurse --keepNewlineAfter
./Presentation.fs has been written.
The following exception occurs while formatting stdin: Fantomas.FormatConfig+FormatException: Parsing failed with errors: [|/tmp.fsx (46,90)-(46,92) parse error Unexpected keyword 'if' in binding. Expected incomplete structured construct at or before this point or other token.;
  /tmp.fsx (61,1)-(61,4) parse error Incomplete structured construct at or before this point in binding. Expected incomplete structured construct at or before this point or other token.;
  /tmp.fsx (38,1)-(38,4) parse error Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.|]
And options: { SourceFiles = [|"/tmp.fsx"|]
  ConditionalCompilationDefines = []
  ErrorSeverityOptions = { WarnLevel = 3
                           GlobalWarnAsError = false
                           WarnOff = []
                           WarnOn = []
                           WarnAsError = []
                           WarnAsWarn = [] }
  IsInteractive = false
  LightSyntax = None
  CompilingFsLib = false
  IsExe = false }
   at Fantomas.CodeFormatterImpl.parse@61-2.Invoke(FSharpParseFileResults _arg2) in C:\Users\nojaf\Projects\fantomas\src\Fantomas\CodeFormatterImpl.fs:line 66
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 417
   at <StartupCode$FSharp-Compiler-Service>.$Service.ParseFile@424-3.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 109
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 350
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 882
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 890
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 1154
   at Fantomas.Cmd.Program.processSourceString(Boolean isFsiFile, String s, FSharpChoice`2 tw, FormatConfig config) in C:\Users\nojaf\Projects\fantomas\src\Fantomas.CoreGlobalTool\Program.fs:line 85
   at Fantomas.Cmd.Program.stringToFile@196(FSharpRef`1 force, FSharpRef`1 profile, String s, String outFile, FormatConfig config) in C:\Users\nojaf\Projects\fantomas\src\Fantomas.CoreGlobalTool\Program.fs:line 204
Force writing original contents to ./Program.fs.
./UserInteraction.fs has been written.
./Properties/AssemblyInfo.fs has been written.

Repro code

  1. Clone https://github.com/knocte/geewallet
  2. Switch to the 'stable' branch.
  3. cd src\GWallet.Frontend.Console
  4. Run fantomas . --recurse --keepNewlineAfter

Current results: crash.
Expected results: shouldn't crash.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions