From 7dc9d8c72b5deb927028e9edfbc6015c5d0296be Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 2 Dec 2011 14:13:12 -0500 Subject: gc: composite literals as per Go 1 R=ken2 CC=golang-dev https://golang.org/cl/5450067 --- test/complit1.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'test/complit1.go') 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" +) -- cgit v1.2.1