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,cmd/compile/internal/types2: type instantiation fails to distinguish similarly named defined types within a package #46592

mdempsky opened this issue Jun 5, 2021 · 2 comments


Copy link

@mdempsky mdempsky commented Jun 5, 2021

This program is invalid, but go/types returns success for type checking it: (Note: The go2go diagnostic is only produced if/after type checking succeeded; contrast

This appears to be because the string produced by instantiatedHash doesn't distinguish package-scope defined types from function-scope defined ones. In CL 324573, I've workaround around this by hacking writeTypeName to include TypeName.Pos when writing type names for instiantiatedHash:

With that change, unified IR is able to successfully compile this test case that exercises a bunch of nested type parameters and similarly named defined types:

/cc @griesemer @findleyr

@mdempsky mdempsky added this to the Go1.18 milestone Jun 5, 2021
@griesemer griesemer self-assigned this Jun 6, 2021
Copy link

@griesemer griesemer commented Jun 6, 2021

instantiatedHash is incorrect for local types (and the comment in the source says so).

Copy link

@gopherbot gopherbot commented Jun 11, 2021

Change mentions this issue: [dev.typeparams] cmd/compile/internal/types2: support local defined types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants