Skip to content

Commit

Permalink
reflect: use same conversion panic in reflect and runtime
Browse files Browse the repository at this point in the history
Consistently say "pointer to array", not "array pointer".

Fixes golang#46743

Change-Id: I2388ec5c16f96e82a3a383b9b462b350686ddc5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/327870
Trust: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
TryBot-Result: Go Bot <[email protected]>
  • Loading branch information
ianlancetaylor committed Jun 14, 2021
1 parent 6bbb0a9 commit 0fd20ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/reflect/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
}
Expand Down

0 comments on commit 0fd20ed

Please sign in to comment.