-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
BadErrorMessageIssues related compiler error messages that should be better.Issues related compiler error messages that should be better.FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
% cat /tmp/x.go
package p
type T[X, Y any] struct {
x X
y Y
}
var _ T[int]
func t(x, y int) int
var _ = t(1)
% go build /tmp/x.go
# command-line-arguments
/tmp/x.go:8:7: got 1 arguments but 2 type parameters
/tmp/x.go:12:11: not enough arguments in call to t
have (number)
want (int, int)
%
Note the difference in errors.
The ordinary parameter error says "not enough arguments in call to t" and then gives the argument types.
The generic error says "got 1 arguments but 2 type parameters" which does not identify the relevant type (T in this case) and is also easily misread to mean "got 1 arguments and got 2 type parameters but these numbers don't match". It would be better for this error to be worded more like the non-generic error. Perhaps:
/tmp/x.go:8:7: not enough type arguments for type T: have 1, want 2
or even
/tmp/x.go:8:7: not enough type arguments for type T
have (int)
want (any, any)
/cc @griesemer
Metadata
Metadata
Assignees
Labels
BadErrorMessageIssues related compiler error messages that should be better.Issues related compiler error messages that should be better.FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.