mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: allow PtrValue.PointTo(nil)
(Argument: For any *PtrValue p, it should always be possible to do: p.PointTo(p.Elem()), even if p.Elem() is nil.) Fixes #1028. R=rsc CC=golang-dev, r https://golang.org/cl/1938044
This commit is contained in:
parent
660ce1425f
commit
a48b35e961
2 changed files with 12 additions and 0 deletions
|
|
@ -384,6 +384,13 @@ func TestPtrPointTo(t *testing.T) {
|
|||
if *ip != 1234 {
|
||||
t.Errorf("got %d, want 1234", *ip)
|
||||
}
|
||||
|
||||
ip = nil
|
||||
vp := NewValue(ip).(*PtrValue)
|
||||
vp.PointTo(vp.Elem())
|
||||
if ip != nil {
|
||||
t.Errorf("got non-nil (%p), want nil", ip)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPtrSetNil(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue