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: calling outgoingCalls from an var func panics #43376

Closed
leitzler opened this issue Dec 25, 2020 · 1 comment
Closed

x/tools/gopls: calling outgoingCalls from an var func panics #43376

leitzler opened this issue Dec 25, 2020 · 1 comment
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@leitzler
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version devel +6d2b3351f6 Thu Dec 10 18:34:40 2020 +0000 darwin/amd64
x/tools: v0.0.0-20201218024724-ae774e9781d2

Does this issue reproduce with the latest release?

Yes

What did you do?

With the cursor over first foo I called textDocument/prepareCallHierarchy and with the returned CallHierarchyItem as parameter callHierarchy/outgoingCalls.

package main

func main() {
    foo := func() {}
    foo()
}

What did you expect to see?

The call to outgoingCalls return (no outgoing calls).

What did you see instead?

gopls crashes with a panic:

panic: ast.Walk: unexpected node type <nil>

goroutine 588 [running]:
go/ast.Walk(0x1adb740, 0xc0008ca360, 0x0, 0x0)
   /Users/leitzler/sdk/gotip/src/go/ast/walk.go:364 +0x30c6
go/ast.Inspect(...)
   /Users/leitzler/sdk/gotip/src/go/ast/walk.go:385
golang.org/x/tools/internal/lsp/source.collectCallExpressions(0xc0003e7140, 0xc0002e3ad0, 0x0, 0x0, 0x1aef7d8, 0xc00028c4e0, 0x4008000000000000, 0x3ff0000000000000, 0xc0008d0120)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/source/call_hierarchy.go:216 +0xc5
golang.org/x/tools/internal/lsp/source.OutgoingCalls(0x1aebd38, 0xc00077fda0, 0x1afd100, 0xc00057a000, 0x1aef7d8, 0xc00028c4e0, 0x4008000000000000, 0x3ff0000000000000, 0x0, 0x0, ...)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/source/call_hierarchy.go:201 +0x351
golang.org/x/tools/internal/lsp.(*Server).outgoingCalls(0xc0001a8460, 0x1aebd38, 0xc0005a7600, 0xc0003f3200, 0x0, 0x0, 0x0, 0x0, 0x0)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/call_hierarchy.go:41 +0x179
golang.org/x/tools/internal/lsp.(*Server).OutgoingCalls(0xc0001a8460, 0x1aebd38, 0xc0005a7600, 0xc0003f3200, 0xc0003f3200, 0x0, 0x0, 0x0, 0x0)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/server_gen.go:132 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0x1aebd38, 0xc0005a7600, 0x1aff718, 0xc0001a8460, 0xc00077fd10, 0x1aebf30, 0xc0005a7580, 0x173093a, 0x1adafc0, 0xc000134010)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/protocol/tsserver.go:231 +0x45e5
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x1aebd38, 0xc0005a7600, 0xc00077fd10, 0x1aebf30, 0xc0005a7580, 0xbff15ad1e083af48, 0x361893def)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/protocol/protocol.go:63 +0xc5
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x1aebd38, 0xc0005a7600, 0xc00077fd10, 0x1aebf30, 0xc0005a7580, 0x0, 0x0)
   /Users/leitzler/proj/tools/outgoing_panic/internal/lsp/lsprpc/lsprpc.go:559 +0x452
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0x1aebd38, 0xc0005a7600, 0xc00053b1d0, 0x1aebf30, 0xc0005a7580, 0x0, 0x0)
   /Users/leitzler/proj/tools/outgoing_panic/internal/jsonrpc2/handler.go:35 +0xd7
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc00010f500, 0xc0008c94a0, 0xc000776170, 0x1aebd38, 0xc0005a7600, 0xc00053b1d0, 0x1aebf30, 0xc0005a7580)
   /Users/leitzler/proj/tools/outgoing_panic/internal/jsonrpc2/handler.go:103 +0x86
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
   /Users/leitzler/proj/tools/outgoing_panic/internal/jsonrpc2/handler.go:100 +0x173

@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 Dec 25, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 25, 2020
@gopherbot
Copy link

Change https://golang.org/cl/279469 mentions this issue: internal/lsp/source: do not panic in "var func" outgoing callhierarchy

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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants