GoPLS Viewer

Home|gopls/go/analysis/passes/nilfunc/testdata/src/a/a.go
1// Copyright 2013 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
5package a
6
7func F() {}
8
9type T struct {
10    F func()
11}
12
13func (TM() {}
14
15var Fv = F
16
17func Comparison() {
18    var t T
19    var fn func()
20    if fn == nil || Fv == nil || t.F == nil {
21        // no error; these func vars or fields may be nil
22    }
23    if F == nil { // want "comparison of function F == nil is always false"
24        panic("can't happen")
25    }
26    if t.M == nil { // want "comparison of function M == nil is always false"
27        panic("can't happen")
28    }
29    if F != nil { // want "comparison of function F != nil is always true"
30        if t.M != nil { // want "comparison of function M != nil is always true"
31            return
32        }
33    }
34    panic("can't happen")
35}
36
MembersX
T.M
Fv
Comparison
Comparison.t
F
T
T.F
Members
X