faldor20 / fsharp-language-server

Other
33 stars 3 forks source link

Hover causing crashes on some functions. #10

Closed faldor20 closed 2 years ago

faldor20 commented 2 years ago

""Any chance you could release a new version of the VSCode extension covering the fix at line 108 in TipFormatter.fs? Thanks!

Later edit: Just noticed that the extension was last updated on the 28th of November. I assume it should include this fix, however I'm still getting the crash when hovering over certain symbols (IE: the "html" function in the new Fable.Lit sample app) ""

geodanila commented 2 years ago

Hi @faldor20!

Just tested using the Fable.Lit sample app (https://github.com/fable-compiler/Fable.Lit) and I'm getting the same behaviour. I'm running VSCode version 1.63.2 on macOS Monterey 12.1 and the F# Language Server updated extension is the latest available version (v0.1.41 - reinstalled it 3 times).

The exception I'm seeing in the F# Language Server Output is the following:

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

Please let me know if I can help in any way.

faldor20 commented 2 years ago

Well, I have no idea how that is happening. Unless I'm grossly misunderstanding something, the function that is being called shouldn't be able to throw that exception. Could even be a bug in the fsharp lang. If you could try to reproduce it in another way that would be great. Just try running this :

let a=[|"a";"b";"d" |]
a|>Array.tryFindIndexBack(fun tag->tag.Text="->"

Also if you could build the package yourself that would be super helpful

If we can't get it resolved easily I'll just put a try-catch block around it and call it a day.

faldor20 commented 2 years ago

I have updated the readme with details as to how you can create a local copy of fsharp language server. I am wondering if it's some strange thing caused by my publishing from windows.

geodanila commented 2 years ago

Building and installing the extension locally solves the issue.

I agree with you, the stracktrace points to code that can no longer throw an exception, since you're using Array.tryFindIndexBack. It's almost like the extension from the VSCode marketplace runs the older code.

faldor20 commented 2 years ago

Okay, I have updated the extension. If you could check if this has fixed the issue that'd be great

geodanila commented 2 years ago

The updated extension works great. Thank you @faldor20 !

faldor20 commented 2 years ago

Thank you! Your were a great help. It's always a pleasure to work with people who are keen to help. :)