1
0
mirror of https://github.com/golang/go synced 2024-11-25 12:57:58 -07:00

reflect: panic if Method index is out of range for a type.

Makes the code agree with the documentation.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4759050
This commit is contained in:
Rob Pike 2011-07-18 11:34:13 +10:00
parent 9d55c282e3
commit 50d90451ff

View File

@ -446,7 +446,7 @@ func (t *commonType) common() *commonType { return t }
func (t *uncommonType) Method(i int) (m Method) { func (t *uncommonType) Method(i int) (m Method) {
if t == nil || i < 0 || i >= len(t.methods) { if t == nil || i < 0 || i >= len(t.methods) {
return panic("reflect: Method index out of range")
} }
p := &t.methods[i] p := &t.methods[i]
if p.name != nil { if p.name != nil {
@ -904,7 +904,7 @@ func toCommonType(p *runtime.Type) *commonType {
} }
x := unsafe.Pointer(p) x := unsafe.Pointer(p)
if uintptr(x)&reflectFlags != 0 { if uintptr(x)&reflectFlags != 0 {
panic("invalid interface value") panic("reflect: invalid interface value")
} }
return &(*hdr)(x).t return &(*hdr)(x).t
} }