faldor20 / fsharp-language-server

Other
33 stars 3 forks source link

type aliases broken #1

Closed faldor20 closed 3 years ago

faldor20 commented 3 years ago

Thanks for working on this! I constantly have to disable and then re-enable Ionide to get autocomplete to work, so having an alternative is great.

I've found a bug though. I'd open an issue on GitHub, but they seem to be disabled. Hovering over a call to a function which is annotated with a type abbreviation causes an exception which causes the extension to stop working. let mustBeAdmin: HttpHandler = requiresRole "Admin" (challenge JwtBearerDefaults.AuthenticationScheme)

Hover over mustBeAdmin
Hover tooltipText=ToolTipText
  [Group
     [{ MainDescription =
         [|val(tag: Keyword);  (tag: Space); mustBeAdmin(tag: Function);
           :(tag: Punctuation);  (tag: Space); HttpHandler(tag: Alias)|]
        XmlDoc = None
        TypeMapping = []
        Remarks =
         Some
           [|Full name(tag: Text); :(tag: Punctuation);  (tag: Space);
             Server(tag: Namespace); .(tag: Punctuation);
             HttpHandlers(tag: Namespace); .(tag: Punctuation);
             mustBeAdmin(tag: ModuleBinding)|]
        ParamName = None }]]
Exception in language server System.Collections.Generic.KeyNotFoundException: An index satisfying the predicate was not found in the collection.
   at Microsoft.FSharp.Primitives.Basics.Array.loop@1017-19[T](FSharpFunc`2 predicate, T[] array, Int32 i) in D:\a\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 1018
   at FSharpLanguageServer.TipFormatter.formatTaggedTexts(TaggedText[] t) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\FSharpLanguageServer\TipFormatter.fs:line 108
   at FSharpLanguageServer.Conversions.asHover(ToolTipText _arg1) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\FSharpLanguageServer\Conversions.fs:line 138
   at FSharpLanguageServer.Program.LSP-Types-ILanguageServer-Hover@662-1.Invoke(FSharpResult`2 c) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\FSharpLanguageServer\Program.fs:line 677
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 464
   at FSharpLanguageServer.Program.recompile@264-5.Invoke(AsyncActivation`1 ctxt) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\FSharpLanguageServer\Program.fs:line 264
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 391
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1044
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1070
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1365
   at LSP.LanguageServer.connect(FSharpFunc`2 serverFactory, BinaryReader receive, BinaryWriter send) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\LSP\LanguageServer.fs:line 116
   at FSharpLanguageServer.Program.main(String[] argv) in C:\Users\Eli\Documents\programming\FSharp\fsharp-language-server\src\FSharpLanguageServer\Program.fs:line 887

I believe this is because formatTaggedTexts wrongly assumes that the signature must contain ->.

faldor20 commented 3 years ago

This should be fixed now

LiteracyFanatic commented 3 years ago

Works great now, thanks.