Skip to content

Commit

Permalink
Fix issue with struct generics and pointer type
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Oct 5, 2024
1 parent a18728a commit e872aec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/server/generics.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
20 changes: 20 additions & 0 deletions tests/completions_test.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e872aec

Please sign in to comment.