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
x/tools/go/types: Type checker does not handle some imported types #9702
Comments
What if you first do |
You wrote domain/domain.go but your impl/impl.go imports test/domain. Can you confirm that your impl.go is importing the domain package that contains domain/domain.go? |
@ianlancetaylor Yes. I wrote the code above as an example, but did a bad job of making it clear. I originally encountered the issue in this code (you need to checkout that specific branch if you want to see for yourself). To @minux's point, yes, running |
It seems a lot of tools expect you to have installed all dependent However, that is certainly not ideal, given that source code is I will leave the judgement to the x/tools developers. /cc @alandonovan and @griesemer |
Used directly, the type checker satisfies direct import dependencies by loading export data for installed packages. This assumes that the packages have been built and installed more recently than their source code was edited. Because this is assumption is often false, the golang.org/x/tools/go/loader package provides a means of loading all dependencies from source code as needed. I recommend that you use that. The stringer tool doesn't use go/loader; perhaps it should. |
Expected behavior as explained above. |
Using Go 1.4.1, it seems that the type checker cannot handle some imported type declarations. This was found using stringer. By way of example, I can create a project with two packages,
domain
andimpl
:domain/domain.go:
impl/impl.go:
Upon invoking
go generate
(and therefore stringer, and therefore the type checker), I get the following error:I would not expect this to cause an issue, given this will compile just fine.
The text was updated successfully, but these errors were encountered: