reflect: change Value.Call results to not be addressable
Leaving them incorrectly marked as addressable broke a use of the text/template package, because state.evalField checks CanAddr and takes the address if it is addressable. Reviewed-on: https://go-review.googlesource.com/21908 From-SVN: r234923
This commit is contained in:
parent
8a434ada27
commit
d90936ff88
3 changed files with 12 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
8edf085a94579bd819a10f50328233812ceeb950
|
8e7b5e777333fa4cd070d96e94ea82e3e1132739
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the last
|
The first line of this file holds the git revision number of the last
|
||||||
merge done from the gofrontend repository.
|
merge done from the gofrontend repository.
|
||||||
|
|
|
@ -1478,6 +1478,12 @@ func TestFunc(t *testing.T) {
|
||||||
if i != 10 || j != 20 || k != 30 || l != (two{40, 50}) || m != 60 || n != 70 || o != 80 {
|
if i != 10 || j != 20 || k != 30 || l != (two{40, 50}) || m != 60 || n != 70 || o != 80 {
|
||||||
t.Errorf("Call returned %d, %d, %d, %v, %d, %g, %d; want 10, 20, 30, [40, 50], 60, 70, 80", i, j, k, l, m, n, o)
|
t.Errorf("Call returned %d, %d, %d, %v, %d, %g, %d; want 10, 20, 30, [40, 50], 60, 70, 80", i, j, k, l, m, n, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, v := range ret {
|
||||||
|
if v.CanAddr() {
|
||||||
|
t.Errorf("result %d is addressable", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type emptyStruct struct{}
|
type emptyStruct struct{}
|
||||||
|
|
|
@ -433,9 +433,11 @@ func (v Value) call(op string, in []Value) []Value {
|
||||||
ret := make([]Value, nout)
|
ret := make([]Value, nout)
|
||||||
results := make([]unsafe.Pointer, nout)
|
results := make([]unsafe.Pointer, nout)
|
||||||
for i := 0; i < nout; i++ {
|
for i := 0; i < nout; i++ {
|
||||||
v := New(t.Out(i))
|
tv := t.Out(i)
|
||||||
results[i] = unsafe.Pointer(v.Pointer())
|
v := New(tv)
|
||||||
ret[i] = Indirect(v)
|
results[i] = v.pointer()
|
||||||
|
fl := flagIndir | flag(tv.Kind())
|
||||||
|
ret[i] = Value{tv.common(), v.pointer(), fl}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pp *unsafe.Pointer
|
var pp *unsafe.Pointer
|
||||||
|
|
Loading…
Add table
Reference in a new issue