From: Ian Lance Taylor Date: Mon, 14 Jun 2021 21:30:46 +0000 (-0700) Subject: reflect: use same conversion panic in reflect and runtime X-Git-Tag: go1.17rc1~106 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0fd20ed5b6;p=gostls13.git reflect: use same conversion panic in reflect and runtime Consistently say "pointer to array", not "array pointer". Fixes #46743 Change-Id: I2388ec5c16f96e82a3a383b9b462b350686ddc5e Reviewed-on: https://go-review.googlesource.com/c/go/+/327870 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Matthew Dempsky TryBot-Result: Go Bot --- diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 17104ad4fa..0db5e13217 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -4371,7 +4371,7 @@ func TestConvertPanic(t *testing.T) { if !v.Type().ConvertibleTo(pt) { t.Errorf("[]byte should be convertible to *[8]byte") } - shouldPanic("reflect: cannot convert slice with length 4 to array pointer with length 8", func() { + shouldPanic("reflect: cannot convert slice with length 4 to pointer to array with length 8", func() { _ = v.Convert(pt) }) } diff --git a/src/reflect/value.go b/src/reflect/value.go index c963a407bc..6ba6202a1a 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -3067,7 +3067,7 @@ func cvtSliceArrayPtr(v Value, t Type) Value { n := t.Elem().Len() h := (*unsafeheader.Slice)(v.ptr) if n > h.Len { - panic("reflect: cannot convert slice with length " + itoa.Itoa(h.Len) + " to array pointer with length " + itoa.Itoa(n)) + panic("reflect: cannot convert slice with length " + itoa.Itoa(h.Len) + " to pointer to array with length " + itoa.Itoa(n)) } return Value{t.common(), h.Data, v.flag&^(flagIndir|flagAddr|flagKindMask) | flag(Ptr)} }