Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(474)

Side by Side Diff: test/complit1.go

Issue 5450067: code review 5450067: gc: composite literals as per Go 1 (Closed)
Patch Set: diff -r cc2107d49e88 https://go.googlecode.com/hg/ Created 12 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/complit.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // errchk $G -e $D/$F.go 1 // errchk $G -e $D/$F.go
2 2
3 // Copyright 2011 The Go Authors. All rights reserved. 3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file. 5 // license that can be found in the LICENSE file.
6 6
7 package main 7 package main
8 8
9 var m map[int][3]int 9 var m map[int][3]int
10
10 func f() [3]int 11 func f() [3]int
11 12
12 func fp() *[3]int 13 func fp() *[3]int
14
13 var mp map[int]*[3]int 15 var mp map[int]*[3]int
14 16
15 var ( 17 var (
16 » _ = [3]int{1,2,3}[:] // ERROR "slice of unaddressable value" 18 » _ = [3]int{1, 2, 3}[:] // ERROR "slice of unaddressable value"
17 » _ = m[0][:] // ERROR "slice of unaddressable value" 19 » _ = m[0][:] // ERROR "slice of unaddressable value"
18 » _ = f()[:] // ERROR "slice of unaddressable value" 20 » _ = f()[:] // ERROR "slice of unaddressable value"
19 » 21
20 // these are okay because they are slicing a pointer to an array 22 // these are okay because they are slicing a pointer to an array
21 » _ = (&[3]int{1,2,3})[:] 23 » _ = (&[3]int{1, 2, 3})[:]
22 _ = mp[0][:] 24 _ = mp[0][:]
23 _ = fp()[:] 25 _ = fp()[:]
24 ) 26 )
27
28 type T struct {
29 » i int
30 » f float64
31 » s string
32 » next *T
33 }
34
35 var (
36 » _ = &T{0, 0, "", nil} // ok
37 » _ = &T{i: 0, f: 0, s: "", next: {}} // ok
38 » _ = &T{0, 0, "", {}} // ERROR "missing type in composite literal"
39 )
OLDNEW
« no previous file with comments | « test/complit.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b