Skip to content

Commit 4a82483

Browse files
committed
Add test with spurious results for go/unreachable-statement
1 parent 0580587 commit 4a82483

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎go/ql/test/query-tests/RedundantCode/UnreachableStatement/CONSISTENCY/CfgConsistency.expected‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
consistencyOverview
2-
| deadEnd | 11 |
2+
| deadEnd | 12 |
3+
| missingInNodeForPostOrInOrder | 1 |
34
deadEnd
45
| main.go:17:2:17:10 | select statement |
56
| main.go:109:2:109:10 | select statement |
@@ -12,3 +13,6 @@ deadEnd
1213
| main.go:157:2:157:10 | select statement |
1314
| main.go:164:2:164:10 | select statement |
1415
| main.go:168:2:168:10 | select statement |
16+
| main.go:200:5:200:11 | implicit-field:0 selection of value |
17+
missingInNodeForPostOrInOrder
18+
| main.go:200:5:200:11 | selection of value |

‎go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
| main.go:153:2:153:22 | return statement | This statement is unreachable. |
1212
| main.go:159:2:159:43 | return statement | This statement is unreachable. |
1313
| main.go:171:2:171:14 | expression statement | This statement is unreachable. |
14+
| main.go:203:2:203:14 | return statement | This statement is unreachable. |

‎go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,21 @@ func test23() {
186186
unreachable() // OK: deliberately unreachable
187187
}
188188

189+
type (
190+
embedded struct{}
191+
recursive struct {
192+
*embedded
193+
value int
194+
*recursive
195+
}
196+
)
197+
198+
func test24(x *recursive) []int {
199+
values := []int{0}
200+
if x.value != 0 {
201+
values = append(values, x.value)
202+
}
203+
return values // $ SPURIOUS: Alert // BUG: reachable because value is a direct field of recursive
204+
}
205+
189206
func main() {}

0 commit comments

Comments
 (0)