blob: 4a469452392b5ca503bb5734e5adf8f0f4e6844e (
plain)
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
|
// Copyright 2020 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 p
type P *struct{}
func _() {
// want an error even if the switch is empty
var a struct{ _ func() }
switch a /* ERROR cannot switch on a */ {
}
switch a /* ERROR cannot switch on a */ {
case a: // no follow-on error here
}
// this is ok because f can be compared to nil
var f func()
switch f {
}
switch f {
case nil:
}
switch (func())(nil) {
case nil:
}
switch (func())(nil) {
case f /* ERROR cannot compare */ :
}
switch nil /* ERROR use of untyped nil in switch expression */ {
}
// this is ok
switch P(nil) {
case P(nil):
}
}
|