diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-12 15:17:30 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-12 15:17:30 -0400 |
| commit | 3ac736266e7019b0628b08da1b540e668568a63f (patch) | |
| tree | e4c85e851a87c7c3e62a0d19c899f3bbd55432ab /src/server | |
| parent | a061543c302e07ed29531289de3fd438ea98e395 (diff) | |
Correctly handle field return values from procs
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 25 | ||||
| -rw-r--r-- | src/server/hover.odin | 8 |
2 files changed, 13 insertions, 20 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 41b2d32..e5a707a 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -943,10 +943,14 @@ get_proc_return_types :: proc( append(&return_types, ret) } else if v, ok := symbol.value.(SymbolProcedureValue); ok { for ret in v.return_types { - if ret.type != nil { - append(&return_types, ret.type) - } else if ret.default_value != nil { - append(&return_types, ret.default_value) + // Need min 1 loop for when return types aren't named, and to loop correctly when we have returns + // like -> (a, b, c: int) + for _ in 0 ..< max(1, len(ret.names)) { + if ret.type != nil { + append(&return_types, ret.type) + } else if ret.default_value != nil { + append(&return_types, ret.default_value) + } } } } @@ -2044,12 +2048,7 @@ get_struct_comp_lit_type :: proc( if field_value, ok := elem.derived.(^ast.Field_Value); ok { // If our field is another comp_lit, check to see if we're actually in that one if cl, ok := field_value.value.derived.(^ast.Comp_Lit); ok { - if type := get_struct_comp_lit_type( - position_context, - cl, - s, - field_name, - ); type != nil { + if type := get_struct_comp_lit_type(position_context, cl, s, field_name); type != nil { return type } } @@ -2267,11 +2266,7 @@ resolve_implicit_selector :: proc( return {}, false } if position_context.parent_comp_lit != nil && position_context.field_value != nil { - return resolve_implicit_selector_comp_literal( - ast_context, - position_context, - current_symbol, - ) + return resolve_implicit_selector_comp_literal(ast_context, position_context, current_symbol) } return current_symbol, ok } diff --git a/src/server/hover.odin b/src/server/hover.odin index cba2234..2c68ad0 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -410,11 +410,9 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> } if resolved, ok := resolve_type_identifier(&ast_context, ident); ok { - if resolved.name != ident.name { - resolved.type_name = resolved.name - resolved.type_pkg = resolved.pkg - resolved.name = ident.name - } + resolved.type_name = resolved.name + resolved.type_pkg = resolved.pkg + resolved.name = ident.name if resolved.type == .Variable { resolved.pkg = ast_context.document_package } |