mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: avoid panic in reflect.Kind.String for negative Kind
Kind(-1).String() used to panic; let's not. Change-Id: I1dfc0e3298beb37d77713d8327579bbde90dd156 Reviewed-on: https://go-review.googlesource.com/c/go/+/393015 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
db3045b4be
commit
0d71234ee4
2 changed files with 11 additions and 2 deletions
|
|
@ -7807,3 +7807,12 @@ func TestIssue50208(t *testing.T) {
|
|||
t.Errorf("name of type parameter mismatched, want:%s, got:%s", want2, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNegativeKindString(t *testing.T) {
|
||||
x := -1
|
||||
s := Kind(x).String()
|
||||
want := "kind-1"
|
||||
if s != want {
|
||||
t.Fatalf("Kind(-1).String() = %q, want %q", s, want)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue