[gopls-release-branch.0.4] internal/lsp/source: add extra nil check in searchForEnclosing

I still keep seeing this crash too, even after CL 244841.

Fixes golang/go#40464

Change-Id: Ic587045e65f34c24bd6df452e24517fd90e36bbe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/245440
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit df70183b18723bb1b3644df7b8305697b554ab81)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/245457
diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go
index 8cf075c..2cabd93 100644
--- a/internal/lsp/source/identifier.go
+++ b/internal/lsp/source/identifier.go
@@ -256,6 +256,9 @@
 						}
 					}
 				}
+				if exported == nil {
+					return nil
+				}
 				return exported
 			}
 		case *ast.CompositeLit: