Commit 773504ae authored by Robert Griesemer's avatar Robert Griesemer

go/importer: don't return packages that are not fully type-checked

Fixes #20837.

Change-Id: I266519c26c8849da267b77e11abe7734d8275112
Reviewed-on: https://go-review.googlesource.com/47074Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 9745e88b
...@@ -136,8 +136,11 @@ func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*type ...@@ -136,8 +136,11 @@ func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*type
} }
pkg, err = conf.Check(bp.ImportPath, p.fset, files, nil) pkg, err = conf.Check(bp.ImportPath, p.fset, files, nil)
if err != nil { if err != nil {
// return (possibly nil or incomplete) package with error (see #16088) // Type-checking stops after the first error (types.Config.Error is not set),
return pkg, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err) // so the returned package is very likely incomplete. Don't return it since
// we don't know its condition: It's very likely unsafe to use and it's also
// not added to p.packages which may cause further problems (issue #20837).
return nil, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err)
} }
p.packages[bp.ImportPath] = pkg p.packages[bp.ImportPath] = pkg
......
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