mirror of https://github.com/golang/go.git
reflect: make Value.Comparable return true for nil interface value
Fixes #65718
This commit is contained in:
parent
daa58db486
commit
c768b4532f
|
|
@ -8024,6 +8024,7 @@ func TestValue_Len(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestValue_Comparable(t *testing.T) {
|
||||
var iNil interface{}
|
||||
var a int
|
||||
var s []int
|
||||
var i interface{} = a
|
||||
|
|
@ -8035,6 +8036,11 @@ func TestValue_Comparable(t *testing.T) {
|
|||
comparable bool
|
||||
deref bool
|
||||
}{
|
||||
{
|
||||
ValueOf(&iNil).Elem(),
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
ValueOf(32),
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -3413,7 +3413,7 @@ func (v Value) Comparable() bool {
|
|||
return v.Type().Comparable()
|
||||
|
||||
case Interface:
|
||||
return v.Elem().Comparable()
|
||||
return v.IsNil() || v.Elem().Comparable()
|
||||
|
||||
case Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
|
|
|
|||
Loading…
Reference in New Issue