Skip to content

Commit 7e8e855

Browse files
committed
Rust: Fix bug when there are no statements.
1 parent 93a0198 commit 7e8e855

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

rust/ql/lib/codeql/rust/elements/internal/StmtListImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module Impl {
3333
AstNode getStmtOrExpr(int index) {
3434
result = this.getStatement(index)
3535
or
36-
index = max(int i | exists(this.getStatement(i))) + 1 and
36+
index = max(int i | i = -1 or exists(this.getStatement(i))) + 1 and
3737
result = this.getTailExpr()
3838
}
3939

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
| StmtList.rs:4:19:9:1 | StmtList | 2 | hasTailExpr | 0:let ... = 1, 1:let ... = 2, 2:... + ... |
22
| StmtList.rs:11:18:15:1 | StmtList | 2 | | 0:let ... = 1, 1:let ... = 2 |
3-
| StmtList.rs:17:19:20:1 | StmtList | 0 | hasTailExpr | |
3+
| StmtList.rs:17:19:20:1 | StmtList | 0 | hasTailExpr | 0:... + ... |
44
| StmtList.rs:22:18:25:1 | StmtList | 1 | | 0:ExprStmt |
55
| StmtList.rs:27:18:29:1 | StmtList | 0 | | |
66
| StmtList.rs:31:18:34:1 | StmtList | 0 | | |
7-
| StmtList.rs:36:29:43:1 | StmtList | 0 | hasTailExpr | |
8-
| StmtList.rs:38:10:40:2 | StmtList | 0 | hasTailExpr | |
9-
| StmtList.rs:40:9:42:2 | StmtList | 0 | hasTailExpr | |
7+
| StmtList.rs:36:29:43:1 | StmtList | 0 | hasTailExpr | 0:if cond {...} else {...} |
8+
| StmtList.rs:38:10:40:2 | StmtList | 0 | hasTailExpr | 0:1 |
9+
| StmtList.rs:40:9:42:2 | StmtList | 0 | hasTailExpr | 0:2 |

0 commit comments

Comments
 (0)