Fatalf("importer: package path %q for pkg index %d", path, len(p.pkgList))
}
+ // see importimport (export.go)
pkg := importpkg
if path != "" {
pkg = mkpkg(path)
}
if pkg.Name == "" {
pkg.Name = name
+ numImport[name]++
} else if pkg.Name != name {
- Fatalf("importer: conflicting package names %s and %s for path %q", pkg.Name, name, path)
+ Yyerror("importer: conflicting package names %s and %s for path %q", pkg.Name, name, path)
+ }
+ if incannedimport == 0 && myimportpath != "" && path == myimportpath {
+ Yyerror("import %q: package depends on %q (import cycle)", importpkg.Path, path)
+ errorexit()
}
p.pkgList = append(p.pkgList, pkg)
return s.Def.Type
}
+// numImport tracks how often a package with a given name is imported.
+// It is used to provide a better error message (by using the package
+// path to disambiguate) if a package that appears multiple times with
+// the same name appears in an error message.
var numImport = make(map[string]int)
func importimport(s *Sym, path string) {
--- /dev/null
+// errorcheckdir -s
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Verify error messages referring to multiple different
+// packages with the same package name.
+
+package ignored