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)
}
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
What did you expect to see?
What did you see instead?
By contrast, this works correctly: