Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: incorrect type in Info.Implicits map #21591

Closed
lvelden opened this issue Aug 24, 2017 · 4 comments
Closed

go/types: incorrect type in Info.Implicits map #21591

lvelden opened this issue Aug 24, 2017 · 4 comments

Comments

@lvelden
Copy link

@lvelden lvelden commented Aug 24, 2017

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

@mvdan mvdan changed the title Incorrect type in types.Info.Implicits map go/types: incorrect type in Info.Implicits map Aug 24, 2017
@mvdan
Copy link
Member

@mvdan mvdan commented Aug 24, 2017

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 24, 2017

Indeed. Definitively looks like a bug.

Loading

@griesemer griesemer added this to the Go1.10 milestone Aug 24, 2017
@griesemer griesemer self-assigned this Aug 24, 2017
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 31, 2017

Theres is an error in the documentation and the implementation:

  1. 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 ".").
  2. 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.)

Fix forthcoming.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 31, 2017

Change https://golang.org/cl/60672 mentions this issue: go/types: fix Info.Implicits entries

Loading

@gopherbot gopherbot closed this in cecba84 Sep 1, 2017
@golang golang locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants