From ec1f92440bcb00d4cf10fee76edcbcee7c88b20c Mon Sep 17 00:00:00 2001 From: Suzy Mueller Date: Tue, 19 Jul 2022 17:38:06 -0400 Subject: [PATCH] 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 Reviewed-by: Robert Findley TryBot-Result: Gopher Robot gopls-CI: kokoro --- internal/lsp/analysis/fillreturns/fillreturns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/lsp/analysis/fillreturns/fillreturns.go b/internal/lsp/analysis/fillreturns/fillreturns.go index 4a30934c63c..705ae124d57 100644 --- a/internal/lsp/analysis/fillreturns/fillreturns.go +++ b/internal/lsp/analysis/fillreturns/fillreturns.go @@ -113,7 +113,7 @@ outer: break } } - if enclosingFunc == nil { + if enclosingFunc == nil || enclosingFunc.Results == nil { continue }