commit | ec1f92440bcb00d4cf10fee76edcbcee7c88b20c | [log] [tgz] |
---|---|---|
author | Suzy Mueller <suzmue@golang.org> | Tue Jul 19 17:38:06 2022 -0400 |
committer | Suzy Mueller <suzmue@golang.org> | Wed Jul 20 19:56:16 2022 +0000 |
tree | 3cc75d1d56da04e94127653b66df5dcdaaf622e3 | |
parent | 79f3242e4b2ee6f1bd987fdd0538e16451f7523e [diff] |
internal/lsp: add check for nil results to fillreturns Avoid panicking when allocating an array for a nil results list by returning early. Change-Id: I26953b5cef7832bad3006bd316d59978a5d94cbd Reviewed-on: https://go-review.googlesource.com/c/tools/+/418416 Run-TryBot: Suzy Mueller <suzmue@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
diff --git a/internal/lsp/analysis/fillreturns/fillreturns.go b/internal/lsp/analysis/fillreturns/fillreturns.go index 4a30934..705ae12 100644 --- a/internal/lsp/analysis/fillreturns/fillreturns.go +++ b/internal/lsp/analysis/fillreturns/fillreturns.go
@@ -113,7 +113,7 @@ break } } - if enclosingFunc == nil { + if enclosingFunc == nil || enclosingFunc.Results == nil { continue }