1
0
mirror of https://github.com/golang/go synced 2024-11-14 17:30:29 -07:00

Fix a npe in test.go

This commit is contained in:
xzhang39 2024-10-08 18:06:58 -07:00
parent 5cb7b6aae3
commit d76568d7ee

View File

@ -546,9 +546,13 @@ func recompileForTest(pmain, preal, ptest, pxtest *Package) *PackageError {
// by x, and then we reverse it.
var stk ImportStack
for p != nil {
tokenPositions := []token.Position{}
if importerOf[p].Internal.Build != nil {
tokenPositions = importerOf[p].Internal.Build.ImportPos[p.ImportPath]
}
stk = append(stk, ImportInfo{
Pkg: p.ImportPath,
Pos: extractFirstImport(importerOf[p].Internal.Build.ImportPos[p.ImportPath]),
Pos: extractFirstImport(tokenPositions),
})
p = importerOf[p]
}