Skip to content

Using --check gives error "todo WhileBang" #3019

@abelbraaksma

Description

@abelbraaksma

Issue created from fantomas-online

Code

let f() = task {
    return true
}

let g() = task {
    while! f() do printfn "testing testing"
}

Result (note: this is expected!)

let f () = task { return true }

let g () =
    task {
        while! f () do
            printfn "testing testing"
    }

Problem description

Having something like the above, actually prevents the formatting and when running:

dotnet fantomas . --check

raises the following exception:

error: Failed to format .\src\FSharp.Control.TaskSeq\TaskSeqInternal.fs: System.Exception: todo for WhileBang
  (Yes (656,20--656,44),
   App
     (Atomic, false,
      LongIdent
        (false,
         SynLongIdent ([e; MoveNextAsync], [(656,28--656,29)], [None; None]),
         None, (656,27--656,42)), Const (Unit, (656,42--656,44)),
      (656,27--656,44)),
   YieldOrReturn
     ((true, false),
      LongIdent
        (false, SynLongIdent ([e; Current], [(657,31--657,32)], [None; None]),
         None, (657,30--657,39)), (657,24--657,39)), (656,20--657,39))
   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.Core.ASTTransformer.collectComputationExpressionStatements(CreationAide creationAide, SynExpr e, FSharpFunc`2 finalContinuation) in /_//src/Fantomas.Core/ASTTransformer.fs:line 345
   at Fantomas.Core.ASTTransformer.mkExpr(CreationAide creationAide, SynExpr e) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1123
   at Fantomas.Core.ASTTransformer.mkExpr(CreationAide creationAide, SynExpr e) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1108
   at Fantomas.Core.ASTTransformer.mkExpr(CreationAide creationAide, SynExpr e) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1384
   at Fantomas.Core.ASTTransformer.mkSynMatchClause(CreationAide creationAide, SynMatchClause _arg4) in /_//src/Fantomas.Core/ASTTransformer.fs:line 376
   at [email protected](SynMatchClause arg10@)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in D:\a\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 246
   at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in D:\a\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 74
   at Fantomas.Core.ASTTransformer.mkExpr(CreationAide creationAide, SynExpr e) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1143
   at Fantomas.Core.ASTTransformer.collectComputationExpressionStatements(CreationAide creationAide, SynExpr e, FSharpFunc`2 finalContinuation) in /_//src/Fantomas.Core/ASTTransformer.fs:line 345
   at Fantomas.Core.ASTTransformer.mkExpr(CreationAide creationAide, SynExpr e) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1123
   at Fantomas.Core.ASTTransformer.mkBinding(CreationAide creationAide, SynBinding _arg7) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1810
   at Fantomas.Core.ASTTransformer.mkModuleDecl(CreationAide creationAide, SynModuleDecl decl) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1971
   at [email protected](FSharpList`1 nodes) in /_//src/Fantomas.Core/ASTTransformer.fs:line 3074
   at Fantomas.Core.ASTTransformer.mkModuleDecl(CreationAide creationAide, SynModuleDecl decl) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1982
   at [email protected](FSharpList`1 nodes) in /_//src/Fantomas.Core/ASTTransformer.fs:line 3074
   at Fantomas.Core.ASTTransformer.mkModuleOrNamespace(CreationAide creationAide, SynModuleOrNamespace mn) in /_//src/Fantomas.Core/ASTTransformer.fs:line 3139
   at [email protected](SynModuleOrNamespace mn)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in D:\a\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 244
   at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in D:\a\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 74
   at Fantomas.Core.ASTTransformer.mkImplFile(CreationAide creationAide, ParsedImplFileInput _arg15, Range m) in /_//src/Fantomas.Core/ASTTransformer.fs:line 3149
   at Fantomas.Core.ASTTransformer.mkOak(FSharpOption`1 sourceText, ParsedInput ast) in /_//src/Fantomas.Core/ASTTransformer.fs:line 3574
   at Fantomas.Core.CodeFormatterImpl.formatAST(ParsedInput ast, FSharpOption`1 sourceText, FormatConfig config, FSharpOption`1 cursor) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 66
   at [email protected](Unit unitVar) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 89
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 446
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
.\src\FSharp.Control.TaskSeq\TaskSeqInternal.fs needs formatting

I wonder if the "todo" can be ignored somehow. It also seems like work has been done already, as the online tool shows it is formatted without error, so maybe I just have to be patient (but reporting anyway in case someone else encounters this).

Appreciate all the good work as always!!! It is also sooo much faster than, say, a year ago!

Extra information

  • The formatted result breaks my code.
  • The formatted result gives tool errors.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved (it breaks the pipeline)

Live example: https://github.com/fsprojects/FSharp.Control.TaskSeq/actions/runs/7256774972/job/19769562682?pr=209

Metadata

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