Skip to content

Commit d8485ee

Browse files
committed
go/internal/gcimporter: return (possibly incomplete) package in case of error
For #16088. Change-Id: Ib38bda06a5c5d110ca86510043775c5cf229e6a8 Reviewed-on: https://go-review.googlesource.com/37756 Reviewed-by: Alan Donovan <[email protected]>
1 parent 63f8cca commit d8485ee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/go/internal/gcimporter/bimport.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ type importer struct {
4747
// and returns the number of bytes consumed and a reference to the package.
4848
// If the export data version is not recognized or the format is otherwise
4949
// compromised, an error is returned.
50-
func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, _ *types.Package, err error) {
50+
func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, pkg *types.Package, err error) {
5151
// catch panics and return them as errors
5252
defer func() {
5353
if e := recover(); e != nil {
5454
// The package (filename) causing the problem is added to this
5555
// error by a wrapper in the caller (Import in gcimporter.go).
56+
// Return a (possibly nil or incomplete) package unchanged (see #16088).
5657
err = fmt.Errorf("cannot import, possibly version skew (%v) - reinstall package", e)
5758
}
5859
}()
@@ -117,7 +118,7 @@ func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []
117118
p.typList = append(p.typList, predeclared...)
118119

119120
// read package data
120-
pkg := p.pkg()
121+
pkg = p.pkg()
121122

122123
// read objects of phase 1 only (see cmd/compiler/internal/gc/bexport.go)
123124
objcount := 0

0 commit comments

Comments
 (0)