aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-21 08:33:39 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-21 08:33:39 -0400
commitff9e32f263fc5aaa229ec64d28f2891b40a012f5 (patch)
tree0572371d60c97f455357fe6d9b05a4c9afd84112
parent789113379206b43f5e1988d807ae3a316174aa7e (diff)
Correctly resolve references for union field pointer types
-rw-r--r--src/server/references.odin4
-rw-r--r--tests/references_test.odin21
2 files changed, 23 insertions, 2 deletions
diff --git a/src/server/references.odin b/src/server/references.odin
index f7be8c6..339be89 100644
--- a/src/server/references.odin
+++ b/src/server/references.odin
@@ -102,8 +102,8 @@ prepare_references :: proc(
found := false
for variant in position_context.union_type.variants {
if position_in_node(variant, position_context.position) {
- if ident, ok := variant.derived.(^ast.Ident); ok {
- symbol, ok = resolve_location_identifier(ast_context, ident^)
+ if ident, _, ok := unwrap_pointer_ident(variant); ok {
+ symbol, ok = resolve_location_identifier(ast_context, ident)
resolve_flag = .Identifier
if !ok {
diff --git a/tests/references_test.odin b/tests/references_test.odin
index 0b8b5c0..d0d99f1 100644
--- a/tests/references_test.odin
+++ b/tests/references_test.odin
@@ -1459,3 +1459,24 @@ ast_references_nested_using_bit_field_field_from_declaration :: proc(t: ^testing
test.expect_reference_locations(t, &source, locations[:])
}
+
+@(test)
+ast_references_union_member_pointer :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ Foo :: struct{}
+
+ Foos :: union {
+ Foo,
+ ^F{*}oo,
+ }
+ `,
+ }
+ locations := []common.Location {
+ {range = {start = {line = 1, character = 2}, end = {line = 1, character = 5}}},
+ {range = {start = {line = 4, character = 3}, end = {line = 4, character = 6}}},
+ {range = {start = {line = 5, character = 4}, end = {line = 5, character = 7}}},
+ }
+
+ test.expect_reference_locations(t, &source, locations[:])
+}