aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/analysis.odin17
-rw-r--r--tests/definition_test.odin28
2 files changed, 45 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 3d5cbc1..65d1140 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1833,6 +1833,23 @@ resolve_implicit_selector :: proc(
}
}
+ if position_context.index != nil {
+ symbol: Symbol
+ ok := false
+ if position_context.previous_index != nil {
+ symbol, ok = resolve_type_expression(ast_context, position_context.previous_index)
+ if !ok {
+ return {}, false
+ }
+ } else {
+ symbol, ok = resolve_type_expression(ast_context, position_context.index.expr)
+ }
+
+ if array, ok := symbol.value.(SymbolFixedArrayValue); ok {
+ return resolve_type_expression(ast_context, array.len)
+ }
+ }
+
if position_context.returns != nil && position_context.function != nil {
return_index: int
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index 35384b6..981adf2 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -30,6 +30,34 @@ ast_goto_bit_set_comp_literal :: proc(t: ^testing.T) {
test.expect_definition_locations(t, &source, {location})
}
+@(test)
+ast_goto_bit_set_index_enumerated_array :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ TestEnum :: enum {
+ valueOne,
+ valueTwo,
+ }
+
+ EnumIndexedArray :: [TestEnum]u32 {
+ .valueOne = 1,
+ .valueTwo = 2,
+ }
+
+ my_proc :: proc() -> u32 {
+ arr :: EnumIndexedArray
+ return arr[.valueO{*}ne]
+ }
+ `,
+ }
+
+ location := common.Location {
+ range = {start = {line = 2, character = 3}, end = {line = 2, character = 11}},
+ }
+
+ test.expect_definition_locations(t, &source, {location})
+}
+
@(test)
ast_goto_comp_lit_field :: proc(t: ^testing.T) {