mirror of
https://github.com/golang/go
synced 2024-11-19 21:34:45 -07:00
reflect: don't panic on delete from nil map.
Fixes #8051 LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/95560046
This commit is contained in:
parent
a43669843b
commit
cb6cb42ede
@ -993,6 +993,9 @@ func TestNilMap(t *testing.T) {
|
||||
if x.Kind() != Invalid {
|
||||
t.Errorf("mbig.MapIndex(\"hello\") for nil map = %v, want Invalid Value", x)
|
||||
}
|
||||
|
||||
// Test that deletes from a nil map succeed.
|
||||
mv.SetMapIndex(ValueOf("hi"), Value{})
|
||||
}
|
||||
|
||||
func TestChan(t *testing.T) {
|
||||
|
@ -990,7 +990,7 @@ func reflect·mapassign(t *MapType, h *Hmap, key *byte, val *byte) {
|
||||
#pragma textflag NOSPLIT
|
||||
func reflect·mapdelete(t *MapType, h *Hmap, key *byte) {
|
||||
if(h == nil)
|
||||
runtime·panicstring("delete from nil map");
|
||||
return; // see bug 8051
|
||||
if(raceenabled) {
|
||||
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapdelete);
|
||||
runtime·racereadobjectpc(key, t->key, runtime·getcallerpc(&t), reflect·mapdelete);
|
||||
|
Loading…
Reference in New Issue
Block a user