-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparisons.go
120 lines (111 loc) · 2.99 KB
/
comparisons.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package comparisons
type (
B int // basic type representative
A [10]func()
L []byte
S struct{ f []byte }
P *S
F func()
I interface{}
M map[string]int
C chan int
)
var (
b B
a A
l L
s S
p P
f F
i I
m M
c C
)
func _() {
_ = nil == nil // ERROR "operator == not defined on untyped nil"
_ = b == b
_ = a /* ERROR "A cannot be compared" */ == a
_ = l /* ERROR "slice can only be compared to nil" */ == l
_ = s /* ERROR "struct containing []byte cannot be compared" */ == s
_ = p == p
_ = f /* ERROR "func can only be compared to nil" */ == f
_ = i == i
_ = m /* ERROR "map can only be compared to nil" */ == m
_ = c == c
_ = b == nil /* ERROR "mismatched types" */
_ = a == nil /* ERROR "mismatched types" */
_ = l == nil
_ = s == nil /* ERROR "mismatched types" */
_ = p == nil
_ = f == nil
_ = i == nil
_ = m == nil
_ = c == nil
_ = nil /* ERROR "operator < not defined on untyped nil" */ < nil
_ = b < b
_ = a /* ERROR "operator < not defined on array" */ < a
_ = l /* ERROR "operator < not defined on slice" */ < l
_ = s /* ERROR "operator < not defined on struct" */ < s
_ = p /* ERROR "operator < not defined on pointer" */ < p
_ = f /* ERROR "operator < not defined on func" */ < f
_ = i /* ERROR "operator < not defined on interface" */ < i
_ = m /* ERROR "operator < not defined on map" */ < m
_ = c /* ERROR "operator < not defined on chan" */ < c
}
func _[
B int,
A [10]func(),
L []byte,
S struct{ f []byte },
P *S,
F func(),
I interface{},
J comparable,
M map[string]int,
C chan int,
](
b B,
a A,
l L,
s S,
p P,
f F,
i I,
j J,
m M,
c C,
) {
_ = b == b
_ = a /* ERROR "incomparable types in type set" */ == a
_ = l /* ERROR "incomparable types in type set" */ == l
_ = s /* ERROR "incomparable types in type set" */ == s
_ = p == p
_ = f /* ERROR "incomparable types in type set" */ == f
_ = i /* ERROR "incomparable types in type set" */ == i
_ = j == j
_ = m /* ERROR "incomparable types in type set" */ == m
_ = c == c
_ = b == nil /* ERROR "mismatched types" */
_ = a == nil /* ERROR "mismatched types" */
_ = l == nil
_ = s == nil /* ERROR "mismatched types" */
_ = p == nil
_ = f == nil
_ = i == nil /* ERROR "mismatched types" */
_ = j == nil /* ERROR "mismatched types" */
_ = m == nil
_ = c == nil
_ = b < b
_ = a /* ERROR "type parameter A cannot use operator <" */ < a
_ = l /* ERROR "type parameter L cannot use operator <" */ < l
_ = s /* ERROR "type parameter S cannot use operator <" */ < s
_ = p /* ERROR "type parameter P cannot use operator <" */ < p
_ = f /* ERROR "type parameter F cannot use operator <" */ < f
_ = i /* ERROR "type parameter I cannot use operator <" */ < i
_ = j /* ERROR "type parameter J cannot use operator <" */ < j
_ = m /* ERROR "type parameter M cannot use operator <" */ < m
_ = c /* ERROR "type parameter C cannot use operator <" */ < c
}