Open ghost opened 1 year ago
Do you have a specific reason for aliasing testing.T
? Thanks.
cc @bcmills
Do you have a specific reason for aliasing
testing.T
? Thanks.
Not really, no. I alias struct pointer types so it becomes impossible to forget the and makes refactoring easier later. But apparently testing.T is special.
hi, I reproduced this error using the provided test code snippet. This error is returned from https://github.com/golang/go/blob/master/src/cmd/go/internal/load/test.go#L770.
And it comes from a type assertion, https://github.com/golang/go/blob/master/src/cmd/go/internal/load/test.go#L575 where go command checks whether the first param holds ast.StarExpr. When aliasing testing.T
, the underlying type for fn.Type.Params.List[0].Type
would be `ast.Ident`.
Seems you can't alias
testing.T
, it confusesgo test
. Confuses Go Playground too.What did you do?
https://go.dev/play/p/21W7rITsLUb
What did you expect to see?
Test results
What did you see instead?
wrong signature for TestLastIndex, must be: func TestLastIndex(t *testing.T)