Debian Codegraph @

quickfix/qf1007/testdata/go1.0/CheckConditionalAssignment/CheckConditionalAssignment.go

raw
1 package pkg
2
3 func foo() bool { return true }
4
5 var bar bool
6 var baz bool
7
8 func fn() {
9 x := false //@ diag(`merge conditional assignment`)
10 if foo() || (bar && !baz) {
11 x = true
12 }
13
14 x = false
15 if foo() || (bar && !baz) {
16 x = true
17 }
18
19 y := false
20 if true {
21 y = true
22 println(y)
23 }
24
25 z := false
26 if true {
27 z = false
28 }
29
30 a := false
31 if true {
32 x = true
33 }
34
35 b := true //@ diag(`merge conditional assignment`)
36 if foo() || (bar && !baz) {
37 b = false
38 }
39
40 c := false
41 if true {
42 c = false
43 }
44
45 d := true
46 if true {
47 d = true
48 }
49
50 _ = x
51 _ = y
52 _ = z
53 _ = a
54 _ = b
55 _ = c
56 _ = d
57 }