cmd/compile, go/importer: minor cleanups
Change-Id: Ic7a1fb0dbbf108052c970a4a830269a5673df7df
Reviewed-on: https://go-review.googlesource.com/21963
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
diff --git a/src/cmd/compile/internal/gc/bexport.go b/src/cmd/compile/internal/gc/bexport.go
index e780bcf..59a85c2 100644
--- a/src/cmd/compile/internal/gc/bexport.go
+++ b/src/cmd/compile/internal/gc/bexport.go
@@ -59,9 +59,8 @@
The export data starts with a single byte indicating the encoding format
(compact, or with debugging information), followed by a version string
-(so we can evolve the encoding if need be), the name of the imported
-package, and a string containing platform-specific information for that
-package.
+(so we can evolve the encoding if need be), and then the package object
+for the exported package (with an empty path).
After this header, two lists of objects and the list of inlined function
bodies follows.
diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go
index 2e80b9f..4a93b5a 100644
--- a/src/cmd/compile/internal/gc/bimport.go
+++ b/src/cmd/compile/internal/gc/bimport.go
@@ -59,9 +59,6 @@
// read package data
p.pkg()
- if p.pkgList[0] != importpkg {
- Fatalf("importer: imported package not found in pkgList[0]")
- }
// defer some type-checking until all types are read in completely
// (parser.go:import_package)
@@ -193,7 +190,12 @@
Fatalf("importer: bad path in import: %q", path)
}
- // an empty path denotes the package we are currently importing
+ // an empty path denotes the package we are currently importing;
+ // it must be the first package we see
+ if (path == "") != (len(p.pkgList) == 0) {
+ panic(fmt.Sprintf("package path %q for pkg index %d", path, len(p.pkgList)))
+ }
+
pkg := importpkg
if path != "" {
pkg = mkpkg(path)