]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: panic if Method index is out of range for a type.
authorRob Pike <r@golang.org>
Mon, 18 Jul 2011 01:34:13 +0000 (11:34 +1000)
committerRob Pike <r@golang.org>
Mon, 18 Jul 2011 01:34:13 +0000 (11:34 +1000)
Makes the code agree with the documentation.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4759050

src/pkg/reflect/type.go

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