File tree 2 files changed +25
-3
lines changed 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func switchStmtChecker(pass *analysis.Pass, cfg config) nodeVisitor {
70
70
if _ , ok := comments [file ]; ! ok {
71
71
comments [file ] = ast .NewCommentMap (pass .Fset , file , file .Comments )
72
72
}
73
- if containsIgnoreDirective (comments [file ]. Filter ( sw ). Comments () ) {
73
+ if containsIgnoreDirective (comments [file ][ sw ] ) {
74
74
// Skip checking of this switch statement due to ignore directive comment.
75
75
// Still return true because there may be nested switch statements
76
76
// that are not to be ignored.
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ func _b() {
27
27
var d Direction
28
28
29
29
// this should not report.
30
- switch d { //exhaustive:ignore
30
+ //exhaustive:ignore
31
+ switch d {
31
32
case N :
32
33
case S :
33
34
case W :
@@ -47,7 +48,8 @@ func _nested() {
47
48
var d Direction
48
49
49
50
// this should not report.
50
- switch d { //exhaustive:ignore
51
+ //exhaustive:ignore
52
+ switch d {
51
53
case N :
52
54
case S :
53
55
case W :
@@ -61,3 +63,23 @@ func _nested() {
61
63
}
62
64
}
63
65
}
66
+
67
+ func _reverse_nested () {
68
+ var d Direction
69
+
70
+ // this should report.
71
+ switch d { // want "^missing cases in switch of type Direction: E, directionInvalid$"
72
+ case N :
73
+ case S :
74
+ case W :
75
+ default :
76
+ // this should not report.
77
+ //exhaustive:ignore
78
+ switch d {
79
+ case N :
80
+ case S :
81
+ case W :
82
+ default :
83
+ }
84
+ }
85
+ }
You can’t perform that action at this time.
0 commit comments