Skip to content

go/types, types2: assignment instead of inference error for invalid generic function assignment #60688

@griesemer

Description

@griesemer
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

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions