aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-10-05 23:51:34 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-10-05 23:51:34 +0200
commite872aec330a4dc5ef8a5ee6f85669b41ff52fc49 (patch)
treef804002fe100ad6fb46719c793a494872ab23be2
parenta18728ada67d36958de97319b85defd940f3c2cd (diff)
Fix issue with struct generics and pointer type
-rw-r--r--src/server/generics.odin4
-rw-r--r--tests/completions_test.odin20
2 files changed, 23 insertions, 1 deletions
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
@@ -2878,6 +2878,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 {
main = `package main