summaryrefslogtreecommitdiff
path: root/test/complit1.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-12-02 14:13:12 -0500
committerRuss Cox <rsc@golang.org>2011-12-02 14:13:12 -0500
commit5940e43ea9f3da262a4d2740986c5d132fde21de (patch)
treec4bc220d6b2d504a65b26e3663006ef149e1033c /test/complit1.go
parent64e6f7ac547df3d1dc0dfbc6056d34e45f56cc16 (diff)
downloadgo-5940e43ea9f3da262a4d2740986c5d132fde21de.tar.gz
gc: composite literals as per Go 1
R=ken2 CC=golang-dev http://codereview.appspot.com/5450067
Diffstat (limited to 'test/complit1.go')
-rw-r--r--test/complit1.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/complit1.go b/test/complit1.go
index 23b3bbd19..f4f7311af 100644
--- a/test/complit1.go
+++ b/test/complit1.go
@@ -7,18 +7,33 @@
package main
var m map[int][3]int
+
func f() [3]int
func fp() *[3]int
+
var mp map[int]*[3]int
var (
- _ = [3]int{1,2,3}[:] // ERROR "slice of unaddressable value"
- _ = m[0][:] // ERROR "slice of unaddressable value"
- _ = f()[:] // ERROR "slice of unaddressable value"
-
+ _ = [3]int{1, 2, 3}[:] // ERROR "slice of unaddressable value"
+ _ = m[0][:] // ERROR "slice of unaddressable value"
+ _ = f()[:] // ERROR "slice of unaddressable value"
+
// these are okay because they are slicing a pointer to an array
- _ = (&[3]int{1,2,3})[:]
+ _ = (&[3]int{1, 2, 3})[:]
_ = mp[0][:]
_ = fp()[:]
-) \ No newline at end of file
+)
+
+type T struct {
+ i int
+ f float64
+ s string
+ next *T
+}
+
+var (
+ _ = &T{0, 0, "", nil} // ok
+ _ = &T{i: 0, f: 0, s: "", next: {}} // ok
+ _ = &T{0, 0, "", {}} // ERROR "missing type in composite literal"
+)