diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-15 13:30:03 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-15 13:30:03 -0400 |
| commit | 428b54c588ba00c84b60ed5d24cec1b264fa5589 (patch) | |
| tree | 5c346c925af49394590f191f8b1c58a167971205 /tests | |
| parent | 156d75278e86764f3754c68121f4ed347e167a8b (diff) | |
Correctly resolve references of proc parameter names
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/references_test.odin | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/references_test.odin b/tests/references_test.odin index 5a4836a..961c0cf 100644 --- a/tests/references_test.odin +++ b/tests/references_test.odin @@ -1001,3 +1001,55 @@ ast_reference_struct_field_map :: proc(t: ^testing.T) { test.expect_reference_locations(t, &source, locations[:]) } + +@(test) +ast_reference_named_parameter_same_as_variable :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + + foo :: proc(a: int) {} + + main :: proc() { + b := "hellope" + foo(a{*} = 0) + } + `, + } + + locations := []common.Location { + {range = {start = {line = 2, character = 14}, end = {line = 2, character = 15}}}, + {range = {start = {line = 6, character = 7}, end = {line = 6, character = 8}}}, + } + test.expect_reference_locations(t, &source, locations[:]) +} + +@(test) +ast_reference_struct_comp_lit_field :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + + Foo :: enum { + A, + B, + } + + Bar :: struct { + foo: Foo, + } + + foo :: proc() -> Bar { + return Bar { + fo{*}o = .A, + } + } + + `, + } + + locations := []common.Location { + {range = {start = {line = 3, character = 3}, end = {line = 3, character = 4}}}, + {range = {start = {line = 13, character = 11}, end = {line = 13, character = 12}}}, + } + + test.expect_reference_locations(t, &source, locations[:]) +} |