File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
test/query-tests/Expressions/ExprHasNoEffect Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -156,5 +156,7 @@ predicate hasNoEffect(Expr e) {
156156 not exists ( fe .getName ( ) )
157157 ) and
158158 // exclude block-level flow type annotations. For example: `(name: empty)`.
159- not e .( ParExpr ) .getExpression ( ) .getLastToken ( ) .getNextToken ( ) .getValue ( ) = ":"
159+ not e .( ParExpr ) .getExpression ( ) .getLastToken ( ) .getNextToken ( ) .getValue ( ) = ":" and
160+ // exclude the first statement of a try block
161+ not e = any ( TryStmt stmt ) .getBody ( ) .getStmt ( 0 ) .( ExprStmt ) .getExpr ( )
160162}
Original file line number Diff line number Diff line change 1+ | try.js:22:9:22:26 | x.ordinaryProperty | This expression has no effect. |
12| tst2.js:3:4:3:4 | 0 | This expression has no effect. |
23| tst.js:3:1:3:2 | 23 | This expression has no effect. |
34| tst.js:5:1:5:2 | 23 | This expression has no effect. |
Original file line number Diff line number Diff line change 1+ function try1 ( x ) {
2+ try {
3+ x . ordinaryProperty ; // OK - try/catch indicates intent to throw exception
4+ } catch ( e ) {
5+ return false ;
6+ }
7+ return true ;
8+ }
9+
10+ function try2 ( x ) {
11+ try {
12+ x . ordinaryProperty ; // OK - try/catch indicates intent to throw exception
13+ return x ;
14+ } catch ( e ) {
15+ return false ;
16+ }
17+ }
18+
19+ function try3 ( x ) {
20+ try {
21+ x . ordinaryProperty ( )
22+ x . ordinaryProperty // NOT OK
23+ return x ;
24+ } catch ( e ) {
25+ return false ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments