diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-11-02 15:50:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-02 15:50:42 -0500 |
| commit | 06822469106aa36774ce26c4e75d5a3ae4c21efc (patch) | |
| tree | 5af39dbbc8fa48fe0d6548c65e9b46583989e1ed | |
| parent | af3a10a0e3030e8360607982d22781b59bcb6cb9 (diff) | |
| parent | 97b78eb0e090f6f5f9027cbc95fff3a2a9c38fba (diff) | |
Merge pull request #1144 from BradLewis/feat/range-over-enum
Support iterating over an enum
| -rw-r--r-- | src/server/locals.odin | 33 | ||||
| -rw-r--r-- | tests/hover_test.odin | 14 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/server/locals.odin b/src/server/locals.odin index 4a542bf..272504d 100644 --- a/src/server/locals.odin +++ b/src/server/locals.odin @@ -914,6 +914,39 @@ get_locals_for_range_stmt :: proc( ) } } + case SymbolEnumValue: + if len(stmt.vals) >= 1 { + if ident, ok := unwrap_ident(stmt.vals[0]); ok { + store_local( + ast_context, + ident, + stmt.expr, + ident.pos.offset, + ident.name, + ast_context.non_mutable_only, + false, + {.Mutable}, + symbol.pkg, + false, + ) + } + } + if len(stmt.vals) >= 2 { + if ident, ok := unwrap_ident(stmt.vals[1]); ok { + store_local( + ast_context, + ident, + make_int_ast(ast_context, ident.pos, ident.end), + ident.pos.offset, + ident.name, + ast_context.non_mutable_only, + false, + {.Mutable}, + symbol.pkg, + false, + ) + } + } } } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 1ee56d4..b598c24 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5394,6 +5394,20 @@ ast_hover_local_const_binary_expr_with_type :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.foo : i32 : 1 + 2") } + +@(test) +ast_hover_loop_over_enum :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum {A, B, C} + main :: proc() { + for f{*}oo in Foo {} + } + + `, + } + test.expect_hover(t, &source, "test.foo: test.Foo") +} /* Waiting for odin fix |