fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
772 stars 194 forks source link

New index syntax fails on raw list #1929

Closed nojaf closed 2 years ago

nojaf commented 3 years ago

Couldn't use the tool.

let y = [ 0; 2; 4 ][1]

returns

System.Exception: cannot determine if synExpr ArrayOrListComputed
  (false,
   Sequential
     (SuppressNeither, true, Const (Int32 0, tmp.fsx (1,10--1,11)),
      Sequential
        (SuppressNeither, true, Const (Int32 2, tmp.fsx (1,13--1,14)),
         Const (Int32 4, tmp.fsx (1,16--1,17)), tmp.fsx (1,13--1,17)),
      tmp.fsx (1,10--1,17)), tmp.fsx (1,8--1,19)) is uppercase or lowercase
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439
   at Fantomas.CodePrinter.addSpaceBeforeParensInFunCall(SynExpr functionOrMethod, SynExpr arg, Context ctx)
   at Fantomas.CodePrinter.addFirstSpace@3266.Invoke(Context ctx) in /app/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 3270
   at Fantomas.CodePrinter.addFirstSpace@3265-1.Invoke(Context ctx)
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 487
   at Fantomas.Context.atIndentLevel@452-6.Invoke(Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 452
   at Fantomas.Context.atIndentLevel(Boolean alsoSetIndent, Int32 level, FSharpFunc`2 f, Context ctx) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 446
   at Fantomas.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 846
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 487
   at Fantomas.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 846
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 487
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 487
   at Fantomas.Context.col[T](FSharpFunc`2 f', IEnumerable`1 c, FSharpFunc`2 f, Context ctx) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 574
   at Fantomas.CodePrinter.genImpFile@82-6.Invoke(Context ctx) in /app/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 82
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /app/.deps/fantomas/src/Fantomas/Context.fs:line 487
   at Fantomas.CodeFormatterImpl.formatWith(ParsedInput ast, FSharpList`1 defines, FSharpList`1 hashTokens, FormatContext formatContext, FormatConfig config) in /app/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 388
   at Fantomas.CodeFormatterImpl.mapping@408-1.Invoke(Unit unitVar) in /app/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 408
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 446
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\workspace\_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)

https://fsprojects.github.io/fantomas-tools/#/ast?data=N4KABGBEAmCmBmBLAdrAzpAXFSAacUiaAYmolmPAIYA2as%2BEkAxgPZwWQ2wAuYAnmAC8YANpgADAG4wAJhkAWMAF1RARmWQQAXyA

nojaf commented 3 years ago

Might be related to https://github.com/dotnet/fsharp/issues/12309