You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for the Implicits map in go/types.Info (https://golang.org/pkg/go/types/#Info) says that an *ast.ImportSpec maps to a *PkgName for dot-imports, instead I get a *Func in the example above.
Running with go1.9rc2 on linux/amd64
The text was updated successfully, but these errors were encountered:
mvdan
changed the title
Incorrect type in types.Info.Implicits map
go/types: incorrect type in Info.Implicits map
Aug 24, 2017
Theres is an error in the documentation and the implementation:
The documentation should not mention dot-imports for *ast.ImportSpec entries in the Implicits map because dot-imports are already explicitly covered by the Defs map (which will have an entry for the special identifier named ".").
The implementation shouldn't add anything for *ast.ImportSpec nodes to the Implicits map. Right now it adds all the objects imported via the dot-import and it maps them all to the one corresponding *ast.ImportSpec. As a result, what is found in Implicits is simple the "last" exported object of that dot-imported package, and what is the "last" object depends on the (random) iteration order over the map of objects of the imported package scope.
(Arguably, dot-imported objects are implicitly defined, but there's no mechanism that permits multiple objects to be associated with a single *ast.ImportSpec; and we're not going to add one.)
In this code I have a dot-import and I want to look up the respective type.Object:
https://play.golang.org/p/vJYe1kUJ0w (The importer doesn't work in the playground, so this has to be run locally)
The documentation for the Implicits map in go/types.Info (https://golang.org/pkg/go/types/#Info) says that an *ast.ImportSpec maps to a *PkgName for dot-imports, instead I get a *Func in the example above.
Running with go1.9rc2 on linux/amd64
The text was updated successfully, but these errors were encountered: