Skip to content

Commit 9198c0d

Browse files
committed
Python: Add NeverReachable test
This looks for nodes annotated with `t[never]` in the test that are reachable in the CFG. This should not happen (it messes with various queries, e.g. the "mixed returns" query), but the test shows that in a few particular cases (involving the `match` statement where all cases contain `return`s), we _do_ have reachable nodes that shouldn't be.
1 parent 2b1165e commit 9198c0d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| test_match.py:159:13:159:13 | IntegerLiteral | Node annotated with t.never is reachable in $@ | test_match.py:151:1:151:42 | Function test_match_exhaustive_return_first | test_match_exhaustive_return_first |
2+
| test_match.py:172:13:172:13 | IntegerLiteral | Node annotated with t.never is reachable in $@ | test_match.py:164:1:164:45 | Function test_match_exhaustive_return_wildcard | test_match_exhaustive_return_wildcard |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Checks that expressions annotated with `t.never` either have no CFG
3+
* node, or if they do, that the node is not reachable from its scope's
4+
* entry (including within the same basic block).
5+
*/
6+
7+
import python
8+
import TimerUtils
9+
import OldCfgImpl
10+
11+
private module Utils = EvalOrderCfgUtils<OldCfg>;
12+
13+
private import Utils::CfgTests
14+
15+
from TimerAnnotation ann
16+
where neverReachable(ann)
17+
select ann, "Node annotated with t.never is reachable in $@", ann.getTestFunction(),
18+
ann.getTestFunction().getName()

0 commit comments

Comments
 (0)