diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2026-01-24 10:01:17 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-24 10:01:17 +1100 |
| commit | 6d117e7abc50050e1c7e9e141a0866587498e403 (patch) | |
| tree | c14dd23e0d3903de6a9d7819829308786a6c71cf | |
| parent | 7a2c58610ac31f815bf058523e3d3a22dc04defe (diff) | |
| parent | ce092169ca1d65b0c66fd2d81b0f00b828cf2e8c (diff) | |
Merge pull request #1260 from BradLewis/fix/parapoly-struct-with-parapoly-child
Correctly resolve child parapoly structs
| -rw-r--r-- | src/server/generics.odin | 10 | ||||
| -rw-r--r-- | tests/completions_test.odin | 28 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/server/generics.odin b/src/server/generics.odin index db858cc..8aa111f 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -793,6 +793,14 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuild v.elem = expr case ^ast.Pointer_Type: v.elem = expr + case ^ast.Call_Expr: + for arg, i in v.args { + if call_ident, ok := arg.derived.(^ast.Ident); ok { + if ident.name == call_ident.name { + v.args[i] = expr + } + } + } } } else if data.parent_proc == nil { data.symbol_value_builder.types[data.i] = expr @@ -806,6 +814,8 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuild data.parent = node case ^ast.Proc_Type: data.parent_proc = v + case ^ast.Call_Expr: + data.parent = v } return visitor diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 53c7fe6..19f5363 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -5299,3 +5299,31 @@ ast_completion_struct_using_named_vector_types :: proc(t: ^testing.T) { } test.expect_completion_docs(t, &source, "", {"Foo.bar: [3]f32", "r: f32", "x: f32"}) } + +@(test) +ast_completion_parapoly_struct_with_parapoly_child :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + SomeEnum :: enum { + enumVal1, + enumVal2 + } + + ChildStruct:: struct($enumGeneric: typeid){ + Something : string, + GenericParam: enumGeneric + } + + ParentStruct :: struct($enumGeneric: typeid){ + ParentSomething: string, + Child: ChildStruct(enumGeneric) + } + + TestGenericStructs :: proc(){ + parent : ParentStruct(SomeEnum) = {}; + parent.Child.{*} + } + `, + } + test.expect_completion_docs(t, &source, "", {"ChildStruct.GenericParam: test.SomeEnum", "ChildStruct.Something: string"}) +} |