Skip to content

Commit 575221b

Browse files
findleyrgopherbot
authored andcommitted
[gopls-release-branch.0.17] gopls/internal/cache/testfuncs: fix crash with *error argument
The test detection logic incorrectly assumes that named types have a non-nil package, which is not true for Error (as we've encountered numerous times). Add the missing nil check. Fixes golang/go#70927 Change-Id: Ibdf483304b53ce219123e820d74acd4f9d12d710 Reviewed-on: https://go-review.googlesource.com/c/tools/+/637815 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit dcc725c) Reviewed-on: https://go-review.googlesource.com/c/tools/+/637736
1 parent 416ad03 commit 575221b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

gopls/internal/cache/testfuncs/tests.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func testKind(sig *types.Signature) (*types.TypeName, bool) {
281281
}
282282

283283
named, ok := ptr.Elem().(*types.Named)
284-
if !ok || named.Obj().Pkg().Path() != "testing" {
284+
if !ok || named.Obj().Pkg() == nil || named.Obj().Pkg().Path() != "testing" {
285285
return nil, false
286286
}
287287

gopls/internal/test/integration/workspace/packages_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func TestFoo2(t *testing.T)
124124
package foo
125125
import "testing"
126126
func TestFoo(t *testing.T)
127+
func Issue70927(*error)
127128
128129
-- foo2_test.go --
129130
package foo_test

0 commit comments

Comments
 (0)