Rust: Fix bug when there are no statements.

This commit is contained in:
Geoffrey White
2025-09-24 16:50:18 +01:00
parent 93a0198326
commit 7e8e855f28
2 changed files with 5 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ module Impl {
AstNode getStmtOrExpr(int index) {
result = this.getStatement(index)
or
index = max(int i | exists(this.getStatement(i))) + 1 and
index = max(int i | i = -1 or exists(this.getStatement(i))) + 1 and
result = this.getTailExpr()
}

View File

@@ -1,9 +1,9 @@
| StmtList.rs:4:19:9:1 | StmtList | 2 | hasTailExpr | 0:let ... = 1, 1:let ... = 2, 2:... + ... |
| StmtList.rs:11:18:15:1 | StmtList | 2 | | 0:let ... = 1, 1:let ... = 2 |
| StmtList.rs:17:19:20:1 | StmtList | 0 | hasTailExpr | |
| StmtList.rs:17:19:20:1 | StmtList | 0 | hasTailExpr | 0:... + ... |
| StmtList.rs:22:18:25:1 | StmtList | 1 | | 0:ExprStmt |
| StmtList.rs:27:18:29:1 | StmtList | 0 | | |
| StmtList.rs:31:18:34:1 | StmtList | 0 | | |
| StmtList.rs:36:29:43:1 | StmtList | 0 | hasTailExpr | |
| StmtList.rs:38:10:40:2 | StmtList | 0 | hasTailExpr | |
| StmtList.rs:40:9:42:2 | StmtList | 0 | hasTailExpr | |
| StmtList.rs:36:29:43:1 | StmtList | 0 | hasTailExpr | 0:if cond {...} else {...} |
| StmtList.rs:38:10:40:2 | StmtList | 0 | hasTailExpr | 0:1 |
| StmtList.rs:40:9:42:2 | StmtList | 0 | hasTailExpr | 0:2 |