Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: panic in completion.enclosingFunction #49397

Closed
jinggangnanyou opened this issue Nov 1, 2021 · 3 comments
Closed

x/tools/gopls: panic in completion.enclosingFunction #49397

jinggangnanyou opened this issue Nov 1, 2021 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@jinggangnanyou
Copy link

gopls version: v0.7.3
gopls flags:
update flags: proxy
extension version: 2021.10.2813
go version: 1.16.9
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Mon, 01 Nov 2021 09:01:20 GMT
restart history:
Mon, 01 Nov 2021 07:28:07 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: interface conversion: types.Type is *types.Basic, not *types.Signature

goroutine 137 [running]:
golang.org/x/tools/internal/lsp/source/completion.enclosingFunction(0xc007332c00, 0x9, 0x10, 0xc00ad5cf50, 0x0)
	  completion.go:1698  0x350
golang.org/x/tools/internal/lsp/source/completion.Completion(0x10beb38, 0xc00ad66990, 0x10d2ab8, 0xc00aa22000, 0x10c2a38, 0xc00aa4d1a0, 0xe0000000b, 0x3ff0000000000000, 0x0, 0x0, ...)
	  completion.go:508  0x8e6
golang.org/x/tools/internal/lsp.(*Server).completion(0xc000770900, 0x10beb38, 0xc00043a080, 0xc00ad5cdc0, 0x0, 0x0, 0x0)
	  completion.go:32  0xf7a
golang.org/x/tools/internal/lsp.(*Server).Completion(0xc000770900, 0x10beb38, 0xc00043a080, 0xc00ad5cdc0, 0xc00ad5cdc0, 0x0, 0x0)
	  server_gen.go:32  0x49
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0x10beb38, 0xc00043a080, 0x10d5fa0, 0xc000770900, 0xc00ad66630, 0x10beda0, 0xc00043a000, 0x0, 0x0, 0x10ad180)
	  tsserver.go:382  0x2784
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x10beb38, 0xc00043a080, 0xc00ad66630, 0x10beda0, 0xc00043a000, 0x0, 0xc0580913dbbb4300)
	  protocol.go:154  0xc5
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x10beb38, 0xc00043a080, 0xc00ad66630, 0x10beda0, 0xc00043a000, 0x0, 0x0)
	  lsprpc.go:506  0x459
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0x10beb38, 0xc00043a080, 0xc00043e180, 0x10beda0, 0xc00043a000, 0xb8ef95b8ef94b8ef, 0xefb0b8ef99b8ef96)
	  handler.go:35  0xd7
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc000038f60, 0xc000434930, 0xc000114d40, 0x10beb38, 0xc00043a080, 0xc00043e180, 0x10beda0, 0xc00043a000)
	  handler.go:103  0x86
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x173
[Error - 5:01:03 PM] 

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@findleyr
Copy link
Contributor

findleyr commented Nov 3, 2021

It's generally an invariant that functions have *Signature type, concerning that it was violated here. I wonder if our AST mangling went wrong.

Nevertheless, we can make that code more defensive.

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: panic in completion.enclosingFunction Nov 5, 2021
@findleyr findleyr transferred this issue from golang/vscode-go Nov 5, 2021
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Nov 5, 2021
@gopherbot gopherbot added this to the Unreleased milestone Nov 5, 2021
@hyangah hyangah added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 8, 2021
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.7.4 Nov 8, 2021
@findleyr findleyr self-assigned this Nov 12, 2021
@gopherbot
Copy link

Change https://golang.org/cl/364675 mentions this issue: internal/lsp/source/completion: avoid invalid AST in enclosingSignature

gopherbot pushed a commit to golang/tools that referenced this issue Nov 17, 2021
Guard against the panic in golang/go#49397, though it should not be
possible with well-formed AST.

Updates golang/go#49397

Change-Id: I3428504a4cfd361c1f51316d8c9aeee4aa9d7f42
Reviewed-on: https://go-review.googlesource.com/c/tools/+/364675
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
@findleyr
Copy link
Contributor

This should be fixed at tip.

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants