Skip to content

Commit 3b424a5

Browse files
committed
internal/lsp/source: handle nil pointer in rename_check.go
Fixes golang/go#42170 Change-Id: Id5b9f5767e952b63482372e5275aa162bc9ab14a Reviewed-on: https://go-review.googlesource.com/c/tools/+/264619 Trust: Rebecca Stambler <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Findley <[email protected]> (cherry picked from commit c8cfbd0) Reviewed-on: https://go-review.googlesource.com/c/tools/+/264625
1 parent 5fb3ff1 commit 3b424a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/lsp/source/rename_check.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ func (r *renamer) checkStructField(from *types.Var) {
390390
// go/types offers no easy way to get from a field (or interface
391391
// method) to its declaring struct (or interface), so we must
392392
// ascend the AST.
393-
pkg, path, _ := pathEnclosingInterval(r.fset, r.packages[from.Pkg()], from.Pos(), from.Pos())
393+
fromPkg, ok := r.packages[from.Pkg()]
394+
if !ok {
395+
return
396+
}
397+
pkg, path, _ := pathEnclosingInterval(r.fset, fromPkg, from.Pos(), from.Pos())
394398
if pkg == nil || path == nil {
395399
return
396400
}

0 commit comments

Comments
 (0)