mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: test that Call results are not addressable
Gccgo was erroneously marking Call results as addressable, which led to an obscure bug using text/template, as text/template calls CanAddr to check whether to take the address of a value when looking up methods. When a function returned a pointer, and CanAddr was true, the result was a pointer to a pointer that had no methods. Fixed in gccgo by https://golang.org/cl/21908. Adding the test here so that it doesn't regress. Change-Id: I1d25b868e1b8e2348b21cbac6404a636376d1a4a Reviewed-on: https://go-review.googlesource.com/21930 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f0c5b8b9c9
commit
982274c96d
1 changed files with 6 additions and 0 deletions
|
|
@ -1476,6 +1476,12 @@ func TestFunc(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
|
||||
for i, v := range ret {
|
||||
if v.CanAddr() {
|
||||
t.Errorf("result %d is addressable", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type emptyStruct struct{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue