summaryrefslogtreecommitdiff
path: root/test/convlit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-02-25 15:11:07 -0800
committerRuss Cox <rsc@golang.org>2010-02-25 15:11:07 -0800
commit3910161307f79fd821148652fb2a77872e7efd52 (patch)
treeed1675a302b1008c7a13de6f750f25e73a3b8d9a /test/convlit.go
parentb86c0b0c4a69aaca1bd748fb2969f90cb2a28310 (diff)
downloadgo-git-3910161307f79fd821148652fb2a77872e7efd52.tar.gz
gc: implement []int(string) and []byte(string)
R=ken2 CC=golang-dev https://golang.org/cl/224060
Diffstat (limited to 'test/convlit.go')
-rw-r--r--test/convlit.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/convlit.go b/test/convlit.go
index e65dad3df6..22415bb324 100644
--- a/test/convlit.go
+++ b/test/convlit.go
@@ -35,3 +35,30 @@ var good2 int = 1.0;
var good3 int = 1e9;
var good4 float = 1e20;
+// explicit conversion of string is okay
+var _ = []int("abc")
+var _ = []byte("abc")
+
+// implicit is not
+var _ []int = "abc" // ERROR "cannot use|incompatible|invalid"
+var _ []byte = "abc" // ERROR "cannot use|incompatible|invalid"
+
+// named string is okay
+type Tstring string
+var ss Tstring = "abc"
+var _ = []int(ss)
+var _ = []byte(ss)
+
+// implicit is still not
+var _ []int = ss // ERROR "cannot use|incompatible|invalid"
+var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
+
+// named slice is not
+type Tint []int
+type Tbyte []byte
+var _ = Tint("abc") // ERROR "convert|incompatible|invalid"
+var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
+
+// implicit is still not
+var _ Tint = "abc" // ERROR "cannot use|incompatible|invalid"
+var _ Tbyte = "abc" // ERROR "cannot use|incompatible|invalid"