9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

L hov panic when used on primitive types with typescript-language-server #71

Closed Superpat closed 4 months ago

Superpat commented 5 months ago

Env

Client version: 9fans.net/acme-lsp@v0.12.0 Typescript LSP version: 4.3.3 Plan9Port version: https://github.com/9fans/plan9port/commit/be7c68f6954f7dcaa53403e0f600716f65a13d32

L hov works fine on variables, functions, complex types and type aliases, but if I try to use it on a literal value or on a primitive type, it fails.

Code example

type A = string

const a: A = "a string"

const b: A[] = [a, a ,a]

What happens for each symbol

hov on type

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x57afd1]

goroutine 1 [running]:
9fans.net/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc000165eb0, {0x630f78, 0x7839e0})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/internal/lsp/acmelsp/remote.go:197 +0xb1
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:230 +0xbcb
main.main()
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:117 +0x65
L: exit 2

hov on A

type A = string

hov on string

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x57afd1]

goroutine 1 [running]:
9fans.net/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc000165eb0, {0x630f78, 0x7839e0})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/internal/lsp/acmelsp/remote.go:197 +0xb1
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:230 +0xbcb
main.main()
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:117 +0x65
L: exit 2
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x57afd1]

hov on const

goroutine 1 [running]:
L: exit 2
9fans.net/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc000151eb0, {0x630f78, 0x7839e0})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/internal/lsp/acmelsp/remote.go:197 +0xb1
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:230 +0xbcb
main.main()
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:117 +0x65

hov on a

const a: string

hov on "a string"

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x57afd1]

goroutine 1 [running]:
9fans.net/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc000165eb0, {0x630f78, 0x7839e0})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/internal/lsp/acmelsp/remote.go:197 +0xb1
main.run(L: exit 2
0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:230 +0xbcb
main.main()
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:117 +0x65

hov on b

const b: string[]

hov while selecting the chars A[]

type A = string

hov with cursor at begining of [a,a,a]

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x57afd1]

goroutine 1 [running]:
9fans.net/acme-lsp/internal/lsp/acmelsp.(*RemoteCmd).Hover(0xc0001a5eb0, {0x630f78, 0x7839e0})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/internal/lsp/acmelsp/remote.go:197 +0xb1
main.run(0xc000000180, {0xc000016050, 0x1, 0x1})
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:230 +0xbcb
main.main()
    /home/patrick/go/pkg/mod/9fans.net/acme-lsp@v0.12.0/cmd/L/main.go:117 +0x65
L: exit 2

hov on any a inside the [a,a,a]

type A = string
farhaven commented 4 months ago

FWIW, I'm seeing this in a few situations with gopls and starpls as well as the Typescript LS. I'll take a stab at fixing this later tonight. It's mostly a matter of "if no information available, don't crash".