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
commit7dc9d8c72b5deb927028e9edfbc6015c5d0296be (patch)
tree3fdff8e3142745f7e26f98395cdb87c8ac62974f /test/complit1.go
parent5f49456465f53f96bee03ac8cbe0d564e31576c2 (diff)
downloadgo-git-7dc9d8c72b5deb927028e9edfbc6015c5d0296be.tar.gz
gc: composite literals as per Go 1
R=ken2 CC=golang-dev https://golang.org/cl/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 23b3bbd192..f4f7311af3 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"
+)