From e872aec330a4dc5ef8a5ee6f85669b41ff52fc49 Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sat, 5 Oct 2024 23:51:34 +0200 Subject: [PATCH] Fix issue with struct generics and pointer type --- src/server/generics.odin | 4 +++- tests/completions_test.odin | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/server/generics.odin b/src/server/generics.odin index 9d5abbc..769a925 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -708,6 +708,8 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, poly_params: ^ast.Field_Li v.elem = expr case ^ast.Dynamic_Array_Type: v.elem = expr + case ^ast.Pointer_Type: + v.elem = expr } } else { data.symbol_value.types[data.i] = expr @@ -717,7 +719,7 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, poly_params: ^ast.Field_Li } #partial switch v in node.derived { - case ^ast.Array_Type, ^ast.Dynamic_Array_Type, ^ast.Selector_Expr: + case ^ast.Array_Type, ^ast.Dynamic_Array_Type, ^ast.Selector_Expr, ^ast.Pointer_Type: data.parent = node } diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 2379ecb..49ac50f 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -2877,6 +2877,26 @@ ast_generics_struct_poly :: proc(t: ^testing.T) { } +@(test) +ast_generics_pointer_poly :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + AAA :: struct($T: typeid) { + value: ^T, + } + + main :: proc() { + ttt: AAA(int) + ttt.{*} + } + `, + } + + test.expect_completion_details(t, &source, ".", {"AAA.value: ^int"}) + +} + + @(test) ast_enumerated_array_index_completion :: proc(t: ^testing.T) { source := test.Source {