File tree 4 files changed +42
-7
lines changed
analyzer/testdata/src/regression 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ func testIssue115() {
4
4
intFunc := func () int { return 19 }
5
5
stringFunc := func () string { return "19" }
6
6
7
- println (13 )
8
- println (43 + 5 )
7
+ println (13 , "!constexpr int" )
8
+ println (43 + 5 , "!constexpr int" )
9
9
10
- println ("foo" ) // want `\Q"foo" is not a constexpr int`
11
- println (intFunc ()) // want `\QintFunc() is not a constexpr int`
12
- println (stringFunc ()) // want `\QstringFunc() is not a constexpr int`
10
+ println ("foo" , "!constexpr int" ) // want `\Q"foo" is not a constexpr int`
11
+ println (intFunc (), "!constexpr int" ) // want `\QintFunc() is not a constexpr int`
12
+ println (stringFunc (), "!constexpr int" ) // want `\QstringFunc() is not a constexpr int`
13
13
}
Original file line number Diff line number Diff line change
1
+ package regression
2
+
3
+ func _ () {
4
+ println ("339" ) // want `\Qpattern1`
5
+ println ("x" ) // want `\Qpattern2`
6
+
7
+ println ("339" ) // want `\Qpattern1`
8
+
9
+ println ("x" )
10
+ }
11
+
12
+ func _ () {
13
+ println ("x" ) // want `\Qpattern2`
14
+ println ("339" ) // want `\Qpattern1`
15
+
16
+ println ("x" ) // want `\Qpattern2`
17
+ println ("339" ) // want `\Qpattern1`
18
+
19
+ println ("x" )
20
+ println ("x" ) // want `\Qpattern2`
21
+ println ("339" )
22
+ }
Original file line number Diff line number Diff line change
1
+ //go:build ignore
1
2
// +build ignore
2
3
3
4
package gorules
@@ -21,7 +22,7 @@ func issue72(m dsl.Matcher) {
21
22
}
22
23
23
24
func issue115 (m dsl.Matcher ) {
24
- m .Match (`println($x)` ).
25
+ m .Match (`println($x, "!constexpr int" )` ).
25
26
Where (! (m ["x" ].Const && m ["x" ].Type .Is ("int" ))).
26
27
Report ("$x is not a constexpr int" )
27
28
}
@@ -45,3 +46,8 @@ func issue291(m dsl.Matcher) {
45
46
At (m ["iota" ]).
46
47
Report ("good, have explicit type" )
47
48
}
49
+
50
+ func issue339 (m dsl.Matcher ) {
51
+ m .Match (`println("339"); println("x")` ).Report ("pattern1" )
52
+ m .Match (`println("x"); println("339")` ).Report ("pattern2" )
53
+ }
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ func (rr *rulesRunner) runRules(n ast.Node) {
233
233
profiling .Leave (rr .bgContext )
234
234
}
235
235
236
- if matched {
236
+ if matched && ! multiMatchTags [ tag ] {
237
237
break
238
238
}
239
239
}
@@ -414,3 +414,10 @@ func truncateText(s string, maxLen int) string {
414
414
right := s [len (s )- rightLen :]
415
415
return left + placeholder + right
416
416
}
417
+
418
+ var multiMatchTags = [nodetag .NumBuckets ]bool {
419
+ nodetag .BlockStmt : true ,
420
+ nodetag .CaseClause : true ,
421
+ nodetag .CommClause : true ,
422
+ nodetag .File : true ,
423
+ }
You can’t perform that action at this time.
0 commit comments