]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: panic on Invalid Interface call
authorGustavo Niemeyer <gustavo@niemeyer.net>
Mon, 15 Aug 2011 17:14:15 +0000 (14:14 -0300)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Mon, 15 Aug 2011 17:14:15 +0000 (14:14 -0300)
This was initially pushed as part of CL 4876046, found
when logic in exp/template was using the method on
an Invalid value.

R=rsc
CC=golang-dev
https://golang.org/cl/4890043

src/pkg/reflect/value.go

index 82985c5751a9e97a77728b1f42e684acf857bef4..87d12bb0b715a9de687f7938b77ab010bb57ffd8 100644 (file)
@@ -860,6 +860,9 @@ func (v Value) Interface() interface{} {
 }
 
 func (iv internalValue) Interface() interface{} {
+       if iv.kind == 0 {
+               panic(&ValueError{"reflect.Value.Interface", iv.kind})
+       }
        if iv.method {
                panic("reflect.Value.Interface: cannot create interface value for method with bound receiver")
        }