File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
src/cmd/compile/internal/noder Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1214,6 +1214,9 @@ func (subst *subster) node(n ir.Node) ir.Node {
1214
1214
if m .Tag != nil && m .Tag .Op () == ir .OTYPESW {
1215
1215
break // Nothing to do here for type switches.
1216
1216
}
1217
+ if m .Tag != nil && ! types .IsComparable (m .Tag .Type ()) {
1218
+ break // Nothing to do here for un-comparable types.
1219
+ }
1217
1220
if m .Tag != nil && ! m .Tag .Type ().IsEmptyInterface () && m .Tag .Type ().HasShape () {
1218
1221
// To implement a switch on a value that is or has a type parameter, we first convert
1219
1222
// that thing we're switching on to an interface{}.
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2022 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ func main () {
10
+ f [int ]()
11
+ }
12
+
13
+ func f [T any ]() {
14
+ switch []T (nil ) {
15
+ case nil :
16
+ default :
17
+ panic ("FAIL" )
18
+ }
19
+
20
+ switch (func () T )(nil ) {
21
+ case nil :
22
+ default :
23
+ panic ("FAIL" )
24
+ }
25
+
26
+ switch (map [int ]T )(nil ) {
27
+ case nil :
28
+ default :
29
+ panic ("FAIL" )
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments