1
2
3
4
5
6
7 package comp_literals
8
9 type S1 struct{
10 x int
11 y float64
12 s string
13 }
14
15 var (
16 _ = { }
17 _ []int = {}
18 _ struct{} = {}
19 _ [10]byte = {1, 2, 3, 9: 10}
20 _ map[string]int = {"foo": 0, "bar": 1}
21 )
22
23
24
25
26
27 func _() []int {
28 return nil
29 return {}
30 return {1, 2, 3}
31 }
32
33 func _() S1 {
34 return {}
35 return {1, 2, "3"}
36 return {1.0, 2, ""}
37 return {s: "foo"}
38 }
39
40 func _() []S1 {
41 return {}
42 return {{}}
43 return {{x: 1}, {y: 2}, {1, 2.0, "3"}}
44 }
45
46 func f(s []int) {
47 s = {}
48 s = {1, 2, 3}
49 s = {0: 0, 1: 1}
50 s = {"foo" }
51 }
52
53
54
55
56
57 type S2 struct {
58 f func(x int)
59 }
60
61 func g1[T any](x T) {}
62
63 var _ S2 = { g1 }
64
View as plain text