aboutsummaryrefslogtreecommitdiff
path: root/test/convlit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-11-22 12:30:02 -0500
committerRuss Cox <rsc@golang.org>2011-11-22 12:30:02 -0500
commit6e3e3809231c71fc30b6d0cdcb1f60c5e6e816ef (patch)
treee1e48c198bc31ca4fe901fac630758382db1151c /test/convlit.go
parentc69d6345daf277b947341ba958458b0a500effe1 (diff)
downloadgo-6e3e3809231c71fc30b6d0cdcb1f60c5e6e816ef.tar.gz
go-6e3e3809231c71fc30b6d0cdcb1f60c5e6e816ef.zip
allow direct conversion between string and named []byte, []rune
The allowed conversions before and after are: type Tstring string type Tbyte []byte type Trune []rune string <-> string // ok string <-> []byte // ok string <-> []rune // ok string <-> Tstring // ok string <-> Tbyte // was illegal, now ok string <-> Trune // was illegal, now ok Tstring <-> string // ok Tstring <-> []byte // ok Tstring <-> []rune // ok Tstring <-> Tstring // ok Tstring <-> Tbyte // was illegal, now ok Tstring <-> Trune // was illegal, now ok Update spec, compiler, tests. Use in a few packages. We agreed on this a few months ago but never implemented it. Fixes #1707. R=golang-dev, gri, r CC=golang-dev https://golang.org/cl/5421057
Diffstat (limited to 'test/convlit.go')
-rw-r--r--test/convlit.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/convlit.go b/test/convlit.go
index 2e3b15bda1..1e82d1f2f5 100644
--- a/test/convlit.go
+++ b/test/convlit.go
@@ -54,12 +54,12 @@ var _ = []byte(ss)
var _ []rune = ss // ERROR "cannot use|incompatible|invalid"
var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
-// named slice is not
+// named slice is now ok
type Trune []rune
type Tbyte []byte
-var _ = Trune("abc") // ERROR "convert|incompatible|invalid"
-var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
+var _ = Trune("abc") // ok
+var _ = Tbyte("abc") // ok
// implicit is still not
var _ Trune = "abc" // ERROR "cannot use|incompatible|invalid"