diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-11 20:05:20 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-11 20:05:20 +0200 |
| commit | b77e2a9bdba0da962a9363712cb2937a426d1c7e (patch) | |
| tree | 5cb578cafb92db9e6b1005e8f4e286d718f218da | |
| parent | 0d4ee28028fb01dfbc5496b5d7056a6c0ac3eeaf (diff) | |
fix resolve poly for proc types
| -rw-r--r-- | src/server/generics.odin | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/server/generics.odin b/src/server/generics.odin index 65271b2..5ba22b8 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -143,7 +143,6 @@ resolve_poly :: proc( } } } - case ^ast.Struct_Type: case ^ast.Dynamic_Array_Type: if call_array, ok := call_node.derived.(^ast.Dynamic_Array_Type); ok { if poly_type, ok := p.elem.derived.(^ast.Poly_Type); ok { @@ -283,6 +282,7 @@ resolve_poly :: proc( if n, ok := call_node.derived.(^ast.Ident); ok { return true } + case ^ast.Struct_Type, ^ast.Proc_Type: case: log.panicf("Unhandled specialization %v", specialization.derived) } @@ -434,6 +434,26 @@ find_and_replace_poly_type :: proc( v.pos.file = expr.pos.file v.end.file = expr.end.file } + case ^ast.Proc_Type: + if v.params != nil { + for param in v.params.list { + if expr, ok := get_poly_map(param.type, poly_map); ok { + param.type = expr + param.pos.file = expr.pos.file + param.end.file = expr.end.file + } + } + } + + if v.results != nil { + for result in v.results.list { + if expr, ok := get_poly_map(result.type, poly_map); ok { + result.type = expr + result.pos.file = expr.pos.file + result.end.file = expr.end.file + } + } + } } return visitor |