1
2
3
4
5 package assignability
6
7
8
9
10
11 func _[TP any](X TP) {
12 b = b
13 a = a
14 l = l
15 s = s
16 p = p
17 f = f
18 i = i
19 m = m
20 c = c
21 d = d
22
23 B = B
24 A = A
25 L = L
26 S = S
27 P = P
28 F = F
29 I = I
30 M = M
31 C = C
32 D = D
33 X = X
34 }
35
36
37
38
39 func _[TP1, TP2 Interface](X1 TP1, X2 TP2) {
40 b = B
41 a = A
42 l = L
43 s = S
44 p = P
45 f = F
46 i = I
47 m = M
48 c = C
49 d = D
50
51 B = b
52 A = a
53 L = l
54 S = s
55 P = p
56 F = f
57 I = i
58 M = m
59 C = c
60 D = d
61 X1 = i
62 X1 = X2
63 }
64
65
66 func _[TP Interface](X TP) {
67 i = d
68 i = D
69 i = X
70 X = i
71 }
72
73
74
75 type (
76 _SendChan = chan<- int
77 _RecvChan = <-chan int
78
79 SendChan _SendChan
80 RecvChan _RecvChan
81 )
82
83 func _[
84 _CC ~_Chan,
85 _SC ~_SendChan,
86 _RC ~_RecvChan,
87
88 CC Chan,
89 SC SendChan,
90 RC RecvChan,
91 ]() {
92 var (
93 _ _SendChan = c
94 _ _RecvChan = c
95 _ _Chan = c
96
97 _ _SendChan = C
98 _ _RecvChan = C
99 _ _Chan = C
100
101 _ SendChan = c
102 _ RecvChan = c
103 _ Chan = c
104
105 _ SendChan = C
106 _ RecvChan = C
107 _ Chan = C
108 _ Chan = make (chan Basic)
109 )
110
111 var (
112 _ _CC = C
113 _ _SC = C
114 _ _RC = C
115
116 _ CC = _CC (nil)
117 _ SC = _CC (nil)
118 _ RC = _CC (nil)
119
120 _ CC = C
121 _ SC = C
122 _ RC = C
123 )
124 }
125
126
127 func _[
128 TP0 any,
129 TP1 ~_Chan,
130 TP2 ~chan int | ~chan byte,
131 ]() {
132 var (
133 _ TP0 = c
134 _ TP0 = C
135 _ TP1 = c
136 _ TP1 = C
137 _ TP2 = c
138 )
139 }
140
141
142 func _[
143 TP0 Interface,
144 TP1 ~_Chan,
145 TP2 ~chan int | ~chan byte,
146 ](X0 TP0, X1 TP1, X2 TP2) {
147 i = X0
148 I = X0
149 c = X1
150 C = X1
151 c = X2
152 }
153
154
155 func _[TP Interface](X TP) {
156 b = nil
157 a = nil
158 l = nil
159 s = nil
160 p = nil
161 f = nil
162 i = nil
163 m = nil
164 c = nil
165 d = nil
166
167 B = nil
168 A = nil
169 L = nil
170 S = nil
171 P = nil
172 F = nil
173 I = nil
174 M = nil
175 C = nil
176 D = nil
177 X = nil
178 }
179
180
181 func _[
182 Int8 ~int8,
183 Int16 ~int16,
184 Int32 ~int32,
185 Int64 ~int64,
186 Int8_16 ~int8 | ~int16,
187 ](
188 i8 Int8,
189 i16 Int16,
190 i32 Int32,
191 i64 Int64,
192 i8_16 Int8_16,
193 ) {
194 b = 42
195 b = 42.0
196
197
198 i8 = -1 << 7
199 i8 = 1<<7 - 1
200 i16 = -1 << 15
201 i16 = 1<<15 - 1
202 i32 = -1 << 31
203 i32 = 1<<31 - 1
204 i64 = -1 << 63
205 i64 = 1<<63 - 1
206
207 i8_16 = -1 << 7
208 i8_16 = 1<<7 - 1
209 i8_16 = - 1 << 15
210 i8_16 = 1 <<15 - 1
211 }
212
213
214
215 type (
216 _Basic = int
217 _Array = [10]int
218 _Slice = []int
219 _Struct = struct{ f int }
220 _Pointer = *int
221 _Func = func(x int) string
222 _Interface = interface{ m() int }
223 _Map = map[string]int
224 _Chan = chan int
225
226 Basic _Basic
227 Array _Array
228 Slice _Slice
229 Struct _Struct
230 Pointer _Pointer
231 Func _Func
232 Interface _Interface
233 Map _Map
234 Chan _Chan
235 Defined _Struct
236 )
237
238 func (Defined) m() int
239
240
241
242 var (
243 b _Basic
244 a _Array
245 l _Slice
246 s _Struct
247 p _Pointer
248 f _Func
249 i _Interface
250 m _Map
251 c _Chan
252 d _Struct
253
254 B Basic
255 A Array
256 L Slice
257 S Struct
258 P Pointer
259 F Func
260 I Interface
261 M Map
262 C Chan
263 D Defined
264 )
265
View as plain text