aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-13 08:50:59 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-13 15:23:36 -0400
commit135e03599cc33831de46181aef69ffce24976f3d (patch)
tree3e4c900b5f7560b6a9c7aaf709e7d3786da795e6
parent20b4d31f49be2f74a3a34d3177f018d358ef2cf8 (diff)
Correctly handle array types of pointers
-rw-r--r--src/server/analysis.odin8
-rw-r--r--tests/type_definition_test.odin26
2 files changed, 31 insertions, 3 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 5cd290d..08965fb 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -824,6 +824,8 @@ resolve_location_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Ex
return {}, true
case ^ast.Array_Type:
return resolve_location_type_expression(ast_context, n.elem)
+ case ^ast.Dynamic_Array_Type:
+ return resolve_location_type_expression(ast_context, n.elem)
case ^ast.Pointer_Type:
return resolve_location_type_expression(ast_context, n.elem)
case ^ast.Comp_Lit:
@@ -2035,9 +2037,9 @@ resolve_location_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide
case ^ast.Basic_Lit:
return {}, true
case ^ast.Array_Type:
- if elem, ok := n.elem.derived.(^ast.Ident); ok {
- return resolve_location_identifier(ast_context, elem^)
- }
+ return resolve_location_type_expression(ast_context, n.elem)
+ case ^ast.Dynamic_Array_Type:
+ return resolve_location_type_expression(ast_context, n.elem)
case ^ast.Selector_Expr:
return resolve_selector_expression(ast_context, n)
case ^ast.Pointer_Type:
diff --git a/tests/type_definition_test.odin b/tests/type_definition_test.odin
index 4c0ef58..e2003df 100644
--- a/tests/type_definition_test.odin
+++ b/tests/type_definition_test.odin
@@ -813,3 +813,29 @@ ast_type_definition_external_package_from_external_proc :: proc(t: ^testing.T) {
test.expect_type_definition_locations(t, &source, {location})
}
+
+@(test)
+ast_type_definition_array_of_pointers :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Foo :: struct {
+ bar: int,
+ }
+
+ main :: proc() {
+ foos := []^Foo{}
+ l := len(f{*}oos)
+ }
+ `,
+ }
+
+ location := common.Location {
+ range = {
+ start = {line = 2, character = 2},
+ end = {line = 2, character = 5},
+ },
+ }
+
+ test.expect_type_definition_locations(t, &source, {location})
+}