aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-17 19:41:00 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-17 19:44:45 -0400
commit753404b760316aed6c612be1c2bb6d6ebf70ebce (patch)
treef31e480002b6177c16d714646772e46df06dcb7c
parent761f556b80abe30d7b2b6c1c692d584eeff91795 (diff)
Correctly type fixed array selector fields
-rw-r--r--src/server/analysis.odin4
-rw-r--r--tests/semantic_tokens_test.odin23
2 files changed, 25 insertions, 2 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index db37ef7..8dc1877 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1405,7 +1405,8 @@ resolve_selector_expression :: proc(ast_context: ^AstContext, node: ^ast.Selecto
set_ast_package_from_symbol_scoped(ast_context, selector)
ok := internal_resolve_type_expression(ast_context, s.expr, &symbol)
- symbol.type = .Variable
+ symbol.type = .Field
+ symbol.flags |= {.Mutable}
return symbol, ok
} else {
value := SymbolFixedArrayValue {
@@ -2489,6 +2490,7 @@ resolve_unresolved_symbol :: proc(ast_context: ^AstContext, symbol: ^Symbol) ->
symbol.signature = ret.signature
symbol.value = ret.value
symbol.pkg = ret.pkg
+ symbol.flags = ret.flags
} else {
return false
}
diff --git a/tests/semantic_tokens_test.odin b/tests/semantic_tokens_test.odin
index 8fd8468..afb6b6a 100644
--- a/tests/semantic_tokens_test.odin
+++ b/tests/semantic_tokens_test.odin
@@ -117,7 +117,28 @@ semantic_tokens_proc_return :: proc(t: ^testing.T) {
test.expect_semantic_tokens(t, &src, {
{1, 2, 3, .Function, {.ReadOnly}}, // [0] foo
{0, 18, 3, .Variable, {}}, // [1] ret
- {0, 5, 3, .Type, {.ReadOnly}}, // [2] proc
+ {0, 5, 3, .Type, {.ReadOnly}}, // [2] int
{1, 3, 3, .Variable, {}}, // [3] ret
})
}
+
+@(test)
+semantic_tokens_fixed_array_fields :: proc(t: ^testing.T) {
+ src := test.Source {
+ main = `package test
+ main :: proc() {
+ foo: [2]f32
+ y := foo.x
+ }
+ `
+ }
+
+ test.expect_semantic_tokens(t, &src, {
+ {1, 2, 4, .Function, {.ReadOnly}}, // [0] main
+ {1, 3, 3, .Variable, {}}, // [1] foo
+ {0, 8, 3, .Type, {.ReadOnly}}, // [2] f32
+ {1, 3, 1, .Variable, {}}, // [3] y
+ {0, 5, 3, .Variable, {}}, // [4] foo
+ {0, 4, 1, .Property, {}}, // [5] x
+ })
+}