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: assignment instead of inference error for invalid generic function assignment #60688

Closed
griesemer opened this issue Jun 8, 2023 · 1 comment
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

type String string

func g[P any](P, string) {}

var f func(int, String) = g

produces the error (playground):

cannot use g (value of type func(int, string)) as func(int, String) value in variable declaration

but String and string are not identical and thus inference should have failed with a different error:

type func[P any](P, string) of g does not match func(int, String)

which is what is reported when g is passed to a function with a func(int, String) argument (playground).

Marking for 1.21 because the fix should not be too hard, but ok to defer to 1.22.

@findleyr for visibilty

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 8, 2023
@griesemer griesemer added this to the Go1.21 milestone Jun 8, 2023
@griesemer griesemer self-assigned this Jun 8, 2023
@griesemer griesemer changed the title go/types, types2: assignment instead of assertion failure for invalid generic function assignment go/types, types2: assignment instead of inference failure for invalid generic function assignment Jun 8, 2023
@griesemer griesemer changed the title go/types, types2: assignment instead of inference failure for invalid generic function assignment go/types, types2: assignment instead of inference error for invalid generic function assignment Jun 8, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/501938 mentions this issue: go/types, types2: use correct inference approach in assignments of generic functions

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