VS Code highlighting Language Server crash

Hi all,

I am experiencing an issue with the Julia Language server on VS Code. I am using the Julia extension v1.6.3 and julia 1.7.2.

In general, the issue seems to be around syntax highlighting generator expressions
The following is some code which provokes the crash:

(
    (start:(start + l))
    for start in 1:20 for l in 7:13
        if begin 
            if (start + l) <= 20
                (start + l) % 2 == 0
            else
                false
            end
        end
)

Note that the code is valid julia, but rather the julia language server doesn’t like it very much. My best guess is that there is an issue with syntax highlighting generator expressions.

And the accompanying output from the julia language server:

┌ Error: Some Julia code in the VS Code extension crashed
└ @ Main c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\error_handler.jl:15
ERROR: offset[433] > sizeof(content)[230]
Stacktrace:
 [1] get_position_at(doc::LanguageServer.Document, offset::Int64)
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\document.jl:233
 [2] Range
   @ c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\document.jl:255 [inlined]
 [3] (::LanguageServer.var"#180#181"{Vector{LanguageServer.DocumentHighlight}, LanguageServer.Document})(ref::CSTParser.EXPR, doc1::LanguageServer.Document, o::Int64)
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\requests\highlight.jl:10
 [4] for_each_ref(f::LanguageServer.var"#180#181"{Vector{LanguageServer.DocumentHighlight}, LanguageServer.Document}, identifier::CSTParser.EXPR)
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\requests\features.jl:271
 [5] textDocument_documentHighlight_request(params::LanguageServer.DocumentHighlightParams, server::LanguageServerInstance, conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\requests\highlight.jl:7
 [6] (::LanguageServer.var"#97#98"{typeof(LanguageServer.textDocument_documentHighlight_request), LanguageServerInstance})(conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::LanguageServer.DocumentHighlightParams)
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\languageserverinstance.jl:251
 [7] dispatch_msg(x::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::JSONRPC.MsgDispatcher, msg::Dict{String, Any})
   @ JSONRPC c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\JSONRPC\src\typed.jl:67
 [8] run(server::LanguageServerInstance)
   @ LanguageServer c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\packages\LanguageServer\src\languageserverinstance.jl:365
 [9] top-level scope
   @ c:\Users\regan\.vscode\extensions\julialang.language-julia-1.6.3\scripts\languageserver\main.jl:96
[Info  - 7:27:56 pm] Connection to server got closed. Server will restart.

This is a bug report and a cry for help!

Should get fixed by Fix get_file_loc for generators by pfitzseb · Pull Request #1037 · julia-vscode/LanguageServer.jl · GitHub.

1 Like

Much appreciated :star_struck: