Skip to content
Snippets Groups Projects
Commit 58e40aec authored by Rob Findley's avatar Rob Findley Committed by Gopher Robot
Browse files

gopls/internal/golang/completion: avoid crash in addFieldItems

For now, be defensive and avoid the crash reported in golang/go#72828.
No attempt was made to reproduce.

Longer term, as the TODO indicates, we should investigate the logic
error that leads to addFieldItems being called with nil surrounding.

Fixes golang/go#72828

Change-Id: I2300406b49fc3d53561b288d42f64793429e3fbd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/659237


Reviewed-by: default avatarJonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
parent be0d52b7
No related branches found
No related tags found
No related merge requests found
......@@ -1177,7 +1177,10 @@ func isValidIdentifierChar(char byte) bool {
// adds struct fields, interface methods, function declaration fields to completion
func (c *completer) addFieldItems(fields *ast.FieldList) {
if fields == nil {
// TODO: in golang/go#72828, we get here with a nil surrounding.
// This indicates a logic bug elsewhere: we should only be interrogating the
// surrounding if it is set.
if fields == nil || c.surrounding == nil {
return
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment