Commit d8485ee2 authored by Robert Griesemer's avatar Robert Griesemer

go/internal/gcimporter: return (possibly incomplete) package in case of error

For #16088.

Change-Id: Ib38bda06a5c5d110ca86510043775c5cf229e6a8
Reviewed-on: https://go-review.googlesource.com/37756Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
parent 63f8cca9
......@@ -47,12 +47,13 @@ type importer struct {
// and returns the number of bytes consumed and a reference to the package.
// If the export data version is not recognized or the format is otherwise
// compromised, an error is returned.
func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, _ *types.Package, err error) {
func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, pkg *types.Package, err error) {
// catch panics and return them as errors
defer func() {
if e := recover(); e != nil {
// The package (filename) causing the problem is added to this
// error by a wrapper in the caller (Import in gcimporter.go).
// Return a (possibly nil or incomplete) package unchanged (see #16088).
err = fmt.Errorf("cannot import, possibly version skew (%v) - reinstall package", e)
}
}()
......@@ -117,7 +118,7 @@ func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []
p.typList = append(p.typList, predeclared...)
// read package data
pkg := p.pkg()
pkg = p.pkg()
// read objects of phase 1 only (see cmd/compiler/internal/gc/bexport.go)
objcount := 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment