Skip to content

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

Closed
@jinggangnanyou

Description

@jinggangnanyou

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>

Activity

findleyr

findleyr commented on Nov 3, 2021

@findleyr
Member

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.

changed the title [-]gopls: automated issue report (crash)[/-] [+]x/tools/gopls: panic in completion.enclosingFunction[/+] on Nov 5, 2021
transferred this issue fromgolang/vscode-goon Nov 5, 2021
added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Nov 5, 2021
added this to the Unreleased milestone on Nov 5, 2021
added
NeedsFixThe path to resolution is known, but the work has not been done.
on Nov 8, 2021
self-assigned this
on Nov 12, 2021
gopherbot

gopherbot commented on Nov 17, 2021

@gopherbot
Contributor

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

findleyr

findleyr commented on Nov 19, 2021

@findleyr
Member

This should be fixed at tip.

locked and limited conversation to collaborators on Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hyangah@gopherbot@jinggangnanyou@findleyr

        Issue actions

          x/tools/gopls: panic in completion.enclosingFunction · Issue #49397 · golang/go