-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone 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.genericsIssue is related to genericsIssue is related to genericsrelease-blocker
Milestone
Description
If you make a typed alias to a function, t.Helper() gets confused about where the error comes from.
What version of Go are you using (go version)?
1.18
Does this issue reproduce with the latest release?
Yes.
What did you do?
https://go.dev/play/p/GOOGiEsdm_O
func Helper[T any](t *testing.T) {
t.Helper()
t.Error("x")
}
var typedHelper = Helper[int]
func TestHelper(t *testing.T) {
Helper[int](t)
typedHelper(t)
}What did you expect to see?
prog.go:13: x
prog.go:14: x
What did you see instead?
prog.go:13: x
prog.go:10: x ← this is the line where typedHelper is defined
By contrast, this works correctly:
func Helper(t *testing.T) {
t.Helper()
t.Error("x")
}
var aliased = Helper
func TestHelper(t *testing.T) {
Helper(t)
aliased(t)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone 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.genericsIssue is related to genericsIssue is related to genericsrelease-blocker