diff options
Diffstat (limited to 'test/complit1.go')
-rw-r--r-- | test/complit1.go | 27 |
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" +) |