Skip to content

Commit 3ff669b

Browse files
committed
internal/lsp: add check for nil package
Fixes golang/go#31604 Change-Id: I60ec000d505c64783e5f51f62d168dc31c2fbe19 Reviewed-on: https://go-review.googlesource.com/c/tools/+/172968 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
1 parent 1e2181f commit 3ff669b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/lsp/source/identifier.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func Identifier(ctx context.Context, v View, f File, pos token.Pos) (*Identifier
5454
func identifier(ctx context.Context, v View, f File, pos token.Pos) (*IdentifierInfo, error) {
5555
fAST := f.GetAST(ctx)
5656
pkg := f.GetPackage(ctx)
57+
if pkg == nil {
58+
return nil, fmt.Errorf("no package for %s", f.URI())
59+
}
5760
if pkg.IsIllTyped() {
5861
return nil, fmt.Errorf("package for %s is ill typed", f.URI())
5962
}

0 commit comments

Comments
 (0)