diff options
author | Ian Lance Taylor <iant@golang.org> | 2012-02-01 15:24:15 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2012-02-01 15:24:15 -0800 |
commit | 3692726f32f4cff4429e893830871d9b50b9816b (patch) | |
tree | 072f3576558c21c7cd340cf10a22ee45edb78317 /test/append.go | |
parent | 4ea5d62e5a0013b21c9d796b41a56e71b19159b6 (diff) | |
download | go-3692726f32f4cff4429e893830871d9b50b9816b.tar.gz go-3692726f32f4cff4429e893830871d9b50b9816b.zip |
test: test append with two different named types with same element type
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5615045
Diffstat (limited to 'test/append.go')
-rw-r--r-- | test/append.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/append.go b/test/append.go index e178f46990..10ce2a613a 100644 --- a/test/append.go +++ b/test/append.go @@ -27,6 +27,7 @@ func main() { } verifyStruct() verifyInterface() + verifyType() } @@ -230,3 +231,17 @@ func verifyInterface() { verify("interface l", append(s), s) verify("interface m", append(s, e...), r) } + +type T1 []int +type T2 []int + +func verifyType() { + // The second argument to append has type []E where E is the + // element type of the first argument. Test that the compiler + // accepts two slice types that meet that requirement but are + // not assignment compatible. The return type of append is + // the type of the first argument. + t1 := T1{1} + t2 := T2{2} + verify("T1", append(t1, t2...), T1{1, 2}) +} |