Skip to content
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

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

Closed
3 of 4 tasks
abelbraaksma opened this issue Dec 19, 2023 · 9 comments
Closed
3 of 4 tasks

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

abelbraaksma opened this issue Dec 19, 2023 · 9 comments

Comments

@abelbraaksma
Copy link
Member

abelbraaksma commented Dec 19, 2023

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 Fantomas.Core.ASTTransformer.mkExpr@1147-8.Invoke(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 Fantomas.Core.ASTTransformer.mkModuleDecls@3074-5.Invoke(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 Fantomas.Core.ASTTransformer.mkModuleDecls@3074-5.Invoke(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 Fantomas.Core.ASTTransformer.mds@3149.Invoke(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 Fantomas.Core.CodeFormatterImpl.formatDocument@89-3.Invoke(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

@nojaf
Copy link
Contributor

nojaf commented Dec 19, 2023

Hi there,

'6.2.3 does not support while!, it was introduced in https://github.com/fsprojects/fantomas/blob/main/CHANGELOG.md#630-alpha-002---2023-11-07

@nojaf nojaf closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
@abelbraaksma
Copy link
Member Author

Great stuff! I missed it somehow in the changelog. I'll wait for next version :).

@dawedawe
Copy link
Member

Great stuff! I missed it somehow in the changelog. I'll wait for next version :).

Or give the alpha a spin ;)
You will most likely find it very stable already.

@abelbraaksma
Copy link
Member Author

I thought about that, but I couldn't find docs how to download the alpha in CI (i.e., dotnet tools update does not seem to pick up alpha versions, even if I specify them). @dawedawe do you know how? And/or where there's instruction to do so?

@abelbraaksma
Copy link
Member Author

abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
@dawedawe
Copy link
Member

What happens if you do a
dotnet tool update fantomas --prerelease ?
That should give you a
"version": "6.3.0-alpha-004",
inside of the manifest.

abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
@abelbraaksma
Copy link
Member Author

Ah, that "just works", awesome! (online there was the suggestion to use --version "*-alpha*" which did not work for me and I didn't look beyond that).

Thanks for the help 🙇.

abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
abelbraaksma added a commit to fsprojects/FSharp.Control.TaskSeq that referenced this issue Dec 19, 2023
@bartelink
Copy link
Member

small aside - if you use the format 6.3.0-alpha.4, i.e. with a dot instead of a dash, each piece between periods is treated as a number from the point of view of sorting and hence doesn't need prefixing (yes, there are stone age versions of nuget that don't respect that, but they are long gone.)

@nojaf
Copy link
Contributor

nojaf commented Dec 20, 2023

No thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants