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, types2: Identical does not fully match pairwise-identical signature type parameters #49722

Closed
findleyr opened this issue Nov 22, 2021 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@findleyr
Copy link
Contributor

In the type checker, our notion of type identity for signatures considers type parameters in the signature declaration identical if they have identical constraints. In other words, it ignores the type parameter names:

Identical(func[P ~int](){}, func[Q ~int](){}) == true

But we don't extend this type parameter identity when comparing parameters or results:

Identical(func[P ~int](P){}, func[Q ~int](Q){}) == false

This is most likely an oversight since it doesn't matter in type-checked code, but we should be consistent.

CC @griesemer

@findleyr findleyr added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 22, 2021
@findleyr findleyr added this to the Go1.18 milestone Nov 22, 2021
@findleyr findleyr self-assigned this Nov 22, 2021
@findleyr
Copy link
Contributor Author

Another incorrect case: we don't substitute correctly.

Identical(func[P1 any, P2 ~*P1](){}; func[Q1 any, Q2 ~*Q1]() {}) == false

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/366178 mentions this issue: go/types: substitute for type parameters in signatures when comparing

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants