-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inference
Milestone
Description
The following program fails:
func Equal(type T comparable)(x, y T) bool {
return x == y
}
func main() {
var x interface{} = 5
var y = 5
fmt.Println(Equal(x, y))
}
The error is:
prog.go2:15:23: type int of y does not match inferred type interface{} for T
Although it's true that the types don't match exactly, it seems to me that it might be nice
to allow the type argument to unify to interface{}
in the same way that we allow
a concrete type to be passed to an interface type.
mmaedel, alien-agent and scotthew1
Metadata
Metadata
Assignees
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inference