Skip to content

go/types, types2: type inference fails when passing the same generic function twice #59956

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

Closed
griesemer opened this issue May 3, 2023 · 2 comments
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@griesemer
Copy link
Contributor

package p

func f(func(int), func(string)) {}

func g[P any](P) {}

func _() {
	f(g, g)
}

produces

x.go:8:7: type func[P any](P) of g does not match func(string)

Analysis (by @findleyr): we need to rename g's type parameters to avoid conflicts.

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels May 3, 2023
@griesemer griesemer added this to the Go1.21 milestone May 3, 2023
@griesemer griesemer self-assigned this May 3, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/492516 mentions this issue: go/types, types2: rename generic function arguments

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/492515 mentions this issue: go/types, types2: make Checker.renameTParams work on any type

gopherbot pushed a commit that referenced this issue May 4, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
This permits the rewrite of type parameters in arbitrary types,
not just tuples.

Preparation for fixing #59956.
For #59338.

Change-Id: I9ccaac1f163051cb837cae2208763cafb1d239cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/492515
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
@golang golang locked and limited conversation to collaborators May 3, 2024
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. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants