Skip to content

reflect: SetMapIndex should not panic on a nil map delete #8051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randall77 opened this issue May 20, 2014 · 2 comments
Closed

reflect: SetMapIndex should not panic on a nil map delete #8051

randall77 opened this issue May 20, 2014 · 2 comments

Comments

@randall77
Copy link
Contributor

package main

import "reflect"

func main() {
    var m map[int]int
    delete(m, 5)
    
    v := reflect.ValueOf(m)
    v.SetMapIndex(reflect.ValueOf(5), reflect.Value{})
}

The first two lines succeed with no panic, as they should.
The second two lines panic with "delete from nil map".
They should silently succeed instead, like the non-reflect version.
@randall77
Copy link
Contributor Author

Comment 1:

This issue was closed by revision cb6cb42.

Status changed to Fixed.

@gopherbot
Copy link
Contributor

Comment 2:

CL https://golang.org/cl/96540051 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants