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