You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was unable to submit this bug using the online tool ("request too large"), but it does reproduce there.
The following is valid F#:
openSystem.IOletf=new StringReader ""
However, Fantomas throws with the following:
System.Exception: Unexpected expression: New
(false, LongIdent (LongIdentWithDots ([StringReader], [])),
Const
(String ("", tmp.fsx (2,25--2,27) IsSynthetic=false),
tmp.fsx (2,25--2,27) IsSynthetic=false),
tmp.fsx (2,8--2,27) IsSynthetic=false)
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1433.Invoke(String message) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1433
at Fantomas.CodePrinter.genExpr(ASTContext astContext, SynExpr synExpr, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 2565
at Fantomas.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 782
at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 441
at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 441
at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 441
at Fantomas.Context.expressionExceedsPageWidth(FSharpFunc`2 beforeShort, FSharpFunc`2 afterShort, FSharpFunc`2 beforeLong, FSharpFunc`2 afterLong, FSharpFunc`2 expr, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 893
at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 441
at Fantomas.Context.col[T](FSharpFunc`2 f', IEnumerable`1 c, FSharpFunc`2 f, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 526
at Fantomas.CodePrinter.genImpFile@96-6.Invoke(Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 96
at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 441
at Fantomas.CodeFormatterImpl.formatWith(ParsedInput ast, FSharpList`1 defines, FSharpList`1 hashTokens, FormatContext formatContext, FormatConfig config) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 395
at Fantomas.CodeFormatterImpl.format@409-1.Invoke(Tuple`3[] _arg1) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 411
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 404
at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
Arguably it should be formatted new StringReader (""); certainly I seem to remember that it's not always valid to omit the parentheses (or, indeed, the space - though I don't know why I seem to remember those).
The text was updated successfully, but these errors were encountered:
We can (and probably should!) work around this ourselves in the code we're trying to format, by changing the code to new StringReader(""). I just raised it because it's a bug; it's not very important.
nojaf
added a commit
to nojaf/fantomas
that referenced
this issue
Jan 15, 2021
I was unable to submit this bug using the online tool ("request too large"), but it does reproduce there.
The following is valid F#:
However, Fantomas throws with the following:
Arguably it should be formatted
new StringReader ("")
; certainly I seem to remember that it's not always valid to omit the parentheses (or, indeed, the space - though I don't know why I seem to remember those).The text was updated successfully, but these errors were encountered: