summaryrefslogtreecommitdiff
path: root/test/append.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2012-02-01 15:24:15 -0800
committerIan Lance Taylor <iant@golang.org>2012-02-01 15:24:15 -0800
commit8e7988882d809a23fd25ed408d170637580a289d (patch)
treebb89623b13be819eb648b96cf5a17a3180e7c6b5 /test/append.go
parent3f07bfd959d9afd2b216bb3c247a19f4080c6805 (diff)
downloadgo-8e7988882d809a23fd25ed408d170637580a289d.tar.gz
test: test append with two different named types with same element type
R=golang-dev, gri CC=golang-dev http://codereview.appspot.com/5615045
Diffstat (limited to 'test/append.go')
-rw-r--r--test/append.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/append.go b/test/append.go
index e178f4699..10ce2a613 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})
+}