File tree 3 files changed +23
-1
lines changed
gopls/internal/analysis/modernize
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ func minmax(pass *analysis.Pass) {
57
57
if equalSyntax (lhs , lhs2 ) {
58
58
if equalSyntax (rhs , a ) && equalSyntax (rhs2 , b ) {
59
59
sign = + sign
60
- } else if equalSyntax (rhs2 , a ) || equalSyntax (rhs , b ) {
60
+ } else if equalSyntax (rhs2 , a ) && equalSyntax (rhs , b ) {
61
61
sign = - sign
62
62
} else {
63
63
return
Original file line number Diff line number Diff line change @@ -92,3 +92,14 @@ func nopeAssignHasIncrementOperator() {
92
92
}
93
93
print (y )
94
94
}
95
+
96
+ // Regression test for https://github.com/golang/go/issues/71721.
97
+ func nopeNotAMinimum (x , y int ) int {
98
+ // A value of -1 or 0 will use a default value (30).
99
+ if x <= 0 {
100
+ y = 30
101
+ } else {
102
+ y = x
103
+ }
104
+ return y
105
+ }
Original file line number Diff line number Diff line change @@ -69,3 +69,14 @@ func nopeAssignHasIncrementOperator() {
69
69
}
70
70
print(y)
71
71
}
72
+
73
+ // Regression test for https://github.com/golang/go/issues/71721.
74
+ func nopeNotAMinimum(x, y int) int {
75
+ // A value of -1 or 0 will use a default value (30).
76
+ if x <= 0 {
77
+ y = 30
78
+ } else {
79
+ y = x
80
+ }
81
+ return y
82
+ }
You can’t perform that action at this time.
0 commit comments