diff --git a/src/reflect/value.go b/src/reflect/value.go index 650da5b02d2627..f441fe92d9f5cd 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1683,6 +1683,9 @@ func (it *MapIter) SetValue(dst Value) { // entry. It returns false when the iterator is exhausted; subsequent // calls to Key, Value, or Next will panic. func (it *MapIter) Next() bool { + if !it.m.IsValid() { + panic("MapIter.Next called on an iterator that does not have an associated map Value") + } if it.it == nil { it.it = unsafe.Pointer(&it.hiter) mapiterinit(it.m.typ, it.m.pointer(), it.it)