aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-11-07 05:22:05 -0500
committerGitHub <noreply@github.com>2025-11-07 05:22:05 -0500
commit0d6f26fa21ceb6c656ed19e008f74091a4cf6686 (patch)
tree2418af84f73a92e36591ae8c8752471b1e54732c
parent8d1626323b163cbce7b467b20d66c723e7605332 (diff)
parentcf74b5f1133217a7454b8b932e818e891ebdefb0 (diff)
Merge pull request #1164 from BradLewis/fix/poly-proc-soa-arrays
Correctly resolve poly proc returns with #soa arrays
-rw-r--r--src/server/generics.odin2
-rw-r--r--src/server/symbol.odin15
-rw-r--r--tests/hover_test.odin15
3 files changed, 30 insertions, 2 deletions
diff --git a/src/server/generics.odin b/src/server/generics.odin
index 37546a2..fc22942 100644
--- a/src/server/generics.odin
+++ b/src/server/generics.odin
@@ -129,7 +129,6 @@ resolve_poly :: proc(
}
case ^ast.Dynamic_Array_Type:
if call_array, ok := call_node.derived.(^ast.Dynamic_Array_Type); ok {
-
if dynamic_array_is_soa(p^) != dynamic_array_is_soa(call_array^) {
return false
}
@@ -636,7 +635,6 @@ resolve_generic_function_symbol :: proc(
append(&return_types, field)
}
-
for param in params {
field := cast(^ast.Field)clone_node(param, ast_context.allocator, nil)
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index 6cf24df..5181ca3 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -821,11 +821,21 @@ symbol_to_expr :: proc(symbol: Symbol, file: string, allocator := context.temp_a
case SymbolDynamicArrayValue:
type := new_type(ast.Dynamic_Array_Type, pos, end, allocator)
type.elem = v.expr
+ if .Soa in symbol.flags {
+ directive := new_type(ast.Basic_Directive, pos, end, allocator)
+ directive.name = "soa"
+ type.tag = directive
+ }
return type
case SymbolFixedArrayValue:
type := new_type(ast.Array_Type, pos, end, allocator)
type.elem = v.expr
type.len = v.len
+ if .Soa in symbol.flags {
+ directive := new_type(ast.Basic_Directive, pos, end, allocator)
+ directive.name = "soa"
+ type.tag = directive
+ }
return type
case SymbolMapValue:
type := new_type(ast.Map_Type, pos, end, allocator)
@@ -837,6 +847,11 @@ symbol_to_expr :: proc(symbol: Symbol, file: string, allocator := context.temp_a
case SymbolSliceValue:
type := new_type(ast.Array_Type, pos, end, allocator)
type.elem = v.expr
+ if .Soa in symbol.flags {
+ directive := new_type(ast.Basic_Directive, pos, end, allocator)
+ directive.name = "soa"
+ type.tag = directive
+ }
return type
case SymbolStructValue:
type := new_type(ast.Struct_Type, pos, end, allocator)
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 20ef118..9a1f47e 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -5556,6 +5556,21 @@ ast_hover_array_of_array_type_x_elem_local_scope :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.foo: [2]int")
}
+
+@(test)
+ast_hover_soa_poly_proc :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ foo :: proc (arr: ^#soa[dynamic]$E) -> #soa^#soa[dynamic]E {}
+
+ main :: proc() {
+ array: #soa[dynamic]struct{}
+ b{*}ar := foo(&array)
+ }
+ `,
+ }
+ test.expect_hover(t, &source, "test.bar: #soa^#soa[dynamic]struct{}")
+}
/*
Waiting for odin fix