aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-09 08:10:48 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-09 10:14:13 -0400
commitc4dfd07a0537041556d7c074ebea60987ffc3d2b (patch)
tree9ecee74df9a13751fc7ba382ac8d79da017030b0 /tests
parenta42400e0c9f1471ec27454476f6fe6c19dc95242 (diff)
Fix goto definition taking you to the field definition instead of the variable declaration when used with a selector expr
Diffstat (limited to 'tests')
-rw-r--r--tests/definition_test.odin54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index ced4256..8718f3a 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -392,3 +392,57 @@ ast_goto_implicit_enum_infer_from_assignment_within_switch :: proc(t: ^testing.T
test.expect_definition_locations(t, &source, {location})
}
+
+@(test)
+ast_goto_variable_declaration_with_selector_expr :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Bar :: struct {
+ foo: int,
+ }
+
+ main :: proc() {
+ bar: [1]Bar
+ b{*}ar[0].foo = 5
+ }
+ `,
+ packages = {},
+ }
+
+ location := common.Location {
+ range = {
+ start = {line = 7, character = 3},
+ end = {line = 7, character = 6},
+ },
+ }
+
+ test.expect_definition_locations(t, &source, {location})
+}
+
+@(test)
+ast_goto_variable_field_definition_with_selector_expr :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Bar :: struct {
+ foo: int,
+ }
+
+ main :: proc() {
+ bar: [1]Bar
+ bar[0].fo{*}o = 5
+ }
+ `,
+ packages = {},
+ }
+
+ location := common.Location {
+ range = {
+ start = {line = 3, character = 3},
+ end = {line = 3, character = 6},
+ },
+ }
+
+ test.expect_definition_locations(t, &source, {location})
+}