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

Open
mdempsky opened this issue Jun 5, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jun 5, 2021

This program is invalid, but go/types returns success for type checking it: https://go2goplay.golang.org/p/F-SWVR4f2dN (Note: The go2go diagnostic is only produced if/after type checking succeeded; contrast https://go2goplay.golang.org/p/o5NZXojNhMX.)

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:

https://go-review.googlesource.com/c/go/+/324573/8/src/cmd/compile/internal/types2/subst.go
https://go-review.googlesource.com/c/go/+/324573/8/src/cmd/compile/internal/types2/typestring.go

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: https://go-review.googlesource.com/c/go/+/324573/8/test/typeparam/nested.go

/cc @griesemer @findleyr

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

@griesemer griesemer commented Jun 6, 2021

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

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 11, 2021

Change https://golang.org/cl/327170 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
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants