aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2025-06-27 15:16:37 +0200
committerGitHub <noreply@github.com>2025-06-27 15:16:37 +0200
commit4c2dfb82fca94dc9279cb3d0e0568e5ddb397db9 (patch)
treeb51fd6265babf551e56d240b40a498977f9c04ee
parent344eea71fbf1863106bc051dbae11534e7dcca74 (diff)
parent54297d32691c180d83d4fab24cd29c6ac7474e26 (diff)
Merge pull request #682 from BradLewis/feat/improve-references-param-expr
Correctly resolve references with param_expr
-rw-r--r--src/server/file_resolve.odin2
-rw-r--r--tests/references_test.odin33
2 files changed, 34 insertions, 1 deletions
diff --git a/src/server/file_resolve.odin b/src/server/file_resolve.odin
index 3a921d4..18f4fae 100644
--- a/src/server/file_resolve.odin
+++ b/src/server/file_resolve.odin
@@ -205,7 +205,7 @@ resolve_node :: proc(node: ^ast.Node, data: ^FileResolveData) {
#partial switch v in n.expr.derived {
// TODO: Should there be more here?
- case ^ast.Selector_Expr, ^ast.Index_Expr, ^ast.Ident:
+ case ^ast.Selector_Expr, ^ast.Index_Expr, ^ast.Ident, ^ast.Paren_Expr:
resolve_node(n.expr, data)
}
} else {
diff --git a/tests/references_test.odin b/tests/references_test.odin
index 136592c..87195b6 100644
--- a/tests/references_test.odin
+++ b/tests/references_test.odin
@@ -383,3 +383,36 @@ ast_reference_variable_declaration_field_with_selector_expr :: proc(t: ^testing.
test.expect_reference_locations(t, &source, locations[:])
}
+
+@(test)
+ast_reference_cast_proc_param_with_param_expr :: proc (t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Foo :: struct{
+ data: int,
+ len: int,
+ }
+
+ Bar :: struct{
+ data: int,
+ len: int,
+ }
+
+ foo :: proc(bu{*}f: ^Foo, n: int) {
+ (cast(^Bar)&buf.data).len -= n
+ buf.r_offset = (buf.r_offset + n) % cap(buf.data)
+ }
+ `,
+ }
+
+ locations := []common.Location {
+ {range = {start = {line = 12, character = 14}, end = {line = 12, character = 17}}},
+ {range = {start = {line = 13, character = 15}, end = {line = 13, character = 18}}},
+ {range = {start = {line = 14, character = 19}, end = {line = 14, character = 22}}},
+ {range = {start = {line = 14, character = 43}, end = {line = 14, character = 46}}},
+ {range = {start = {line = 14, character = 3}, end = {line = 14, character = 6}}},
+ }
+
+ test.expect_reference_locations(t, &source, locations[:])
+}