-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
BadErrorMessageIssues related compiler error messages that should be better.Issues related compiler error messages that should be better.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.genericsIssue is related to genericsIssue is related to generics
Milestone
Description
What version of Go are you using (go version)?
$ go version go version devel go1.21-af8f94e3c5 Tue Jul 11 21:30:51 2023 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
N/A
What did you do?
https://go.dev/play/p/WWBorJLIgwe?v=gotip
package main
func main() {}
func New[T any](x any) {
f(x.(I[T]))
}
func f[T I[T]](t T) {}
type I[T any] interface {
M(t T)
}
What did you expect to see?
A more helpful error message.
What did you see instead?
./prog.go:6:3: T (type I[T]) does not satisfy I[T] (wrong type for method M)
have M(T)
want M(T)
AIUI, the actual error stems from the fact that the receiver type does not match the type in the method argument, but the error message only includes the method signature, which makes it hard to see what the actual problem is, particular in the context of a much larger program.
Metadata
Metadata
Assignees
Labels
BadErrorMessageIssues related compiler error messages that should be better.Issues related compiler error messages that should be better.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.genericsIssue is related to genericsIssue is related to generics
Type
Projects
Status
Todo