aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-11 21:12:31 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-11 21:12:31 -0400
commite90a29ed4682530243e10ae91e880ed2eeba4dfd (patch)
treed081166740bd969c3caa811f5b05b2993eb7b39e
parent968712e40186abaf5447f69cc73b197af9d94600 (diff)
Correctly resolve go to definition for nested using bitfields on structs
-rw-r--r--src/server/analysis.odin2
-rw-r--r--src/server/symbol.odin9
-rw-r--r--tests/definition_test.odin48
3 files changed, 56 insertions, 3 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 4f70fbd..7538fe1 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -3432,7 +3432,7 @@ make_symbol_struct_from_ast :: proc(
}
b := symbol_struct_value_builder_make(symbol, ast_context.allocator)
- write_struct_type(ast_context, &b, v, attributes, -1, inlined)
+ write_struct_type(ast_context, &b, v, attributes, -1)
symbol = to_symbol(b)
return symbol
}
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index 3d176f1..f140694 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -378,7 +378,6 @@ write_struct_type :: proc(
v: ^ast.Struct_Type,
attributes: []^ast.Attribute,
base_using_index: int,
- inlined := false,
) {
b.poly = v.poly_params
// We clone this so we don't override docs and comments with temp allocated docs and comments
@@ -542,7 +541,7 @@ expand_usings :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuilder) {
if ident, ok := derived.(^ast.Ident); ok {
if v, ok := struct_type_from_identifier(ast_context, ident^); ok {
- write_struct_type(ast_context, b, v, {}, u, true)
+ write_struct_type(ast_context, b, v, {}, u)
} else {
clear(&ast_context.recursion_map)
if symbol, ok := resolve_type_identifier(ast_context, ident^); ok {
@@ -563,6 +562,12 @@ expand_usings :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuilder) {
}
} else if v, ok := derived.(^ast.Struct_Type); ok {
write_struct_type(ast_context, b, v, {}, u)
+ } else if v, ok := derived.(^ast.Bit_Field_Type); ok {
+ if symbol, ok := resolve_type_expression(ast_context, field_expr); ok {
+ if v, ok := symbol.value.(SymbolBitFieldValue); ok {
+ write_symbol_bitfield_value(ast_context, b, v, u)
+ }
+ }
}
delete_key(&ast_context.recursion_map, b.types[u])
}
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index 261ef83..6e7c7a4 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -627,3 +627,51 @@ ast_goto_soa_field :: proc(t: ^testing.T) {
test.expect_definition_locations(t, &source, locations[:])
}
+
+@(test)
+ast_goto_nested_using_bit_field_field :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ Foo :: struct {
+ a: int,
+ using _: bit_field u8 {
+ b: u8 | 4
+ }
+ }
+
+ main :: proc() {
+ foo: Foo
+ b := foo.b{*}
+ }
+ `,
+ }
+ locations := []common.Location {
+ {range = {start = {line = 4, character = 4}, end = {line = 4, character = 5}}},
+ }
+
+ test.expect_definition_locations(t, &source, locations[:])
+}
+
+@(test)
+ast_goto_nested_using_struct_field :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ Foo :: struct {
+ a: int,
+ using _: struct {
+ b: u8
+ }
+ }
+
+ main :: proc() {
+ foo: Foo
+ b := foo.b{*}
+ }
+ `,
+ }
+ locations := []common.Location {
+ {range = {start = {line = 4, character = 4}, end = {line = 4, character = 5}}},
+ }
+
+ test.expect_definition_locations(t, &source, locations[:])
+}