aboutsummaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2021-12-25 13:49:44 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2021-12-25 13:49:44 +0100
commita8abdc0d123b57549b3beee6fc9a1532a7296219 (patch)
tree4d87f737c6a906015c28806dc8525080fb8b6446 /src/analysis
parent74d5978d86d8da1e2f74727965d7d3d3b16c71f1 (diff)
Fix naked blocks being part of locals outside of the scope.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/analysis.odin15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/analysis/analysis.odin b/src/analysis/analysis.odin
index 6fa8d67..b772aac 100644
--- a/src/analysis/analysis.odin
+++ b/src/analysis/analysis.odin
@@ -1946,9 +1946,7 @@ get_locals_stmt :: proc(file: ast.File, stmt: ^ast.Stmt, ast_context: ^AstContex
case If_Stmt:
get_locals_if_stmt(file, v, ast_context, document_position);
case Block_Stmt:
- for stmt in v.stmts {
- get_locals_stmt(file, stmt, ast_context, document_position);
- }
+ get_locals_block_stmt(file, v, ast_context, document_position);
case Proc_Lit:
get_locals_stmt(file, v.body, ast_context, document_position);
case Assign_Stmt:
@@ -1969,6 +1967,17 @@ get_locals_stmt :: proc(file: ast.File, stmt: ^ast.Stmt, ast_context: ^AstContex
}
}
+get_locals_block_stmt :: proc(file: ast.File, block: ast.Block_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) {
+
+ if !(block.pos.offset <= document_position.position && document_position.position <= block.end.offset) {
+ return;
+ }
+
+ for stmt in block.stmts {
+ get_locals_stmt(file, stmt, ast_context, document_position);
+ }
+}
+
get_locals_using_stmt :: proc(stmt: ast.Using_Stmt, ast_context: ^AstContext) {
for u in stmt.list {