diff options
| -rw-r--r-- | src/server/analysis.odin | 17 | ||||
| -rw-r--r-- | tests/hover_test.odin | 33 |
2 files changed, 46 insertions, 4 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 45bf0fd..c9a6275 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1223,13 +1223,22 @@ internal_resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Ex case ^Comp_Lit: return internal_resolve_type_expression(ast_context, v.type, out) case ^Unary_Expr: + ok := internal_resolve_type_expression(ast_context, v.expr, out) if v.op.kind == .And { - ok := internal_resolve_type_expression(ast_context, v.expr, out) out.pointers += 1 - return ok - } else { - return internal_resolve_type_expression(ast_context, v.expr, out) + } else if v.op.kind == .Sub || v.op.kind == .Add { + if value, ok := out.value.(SymbolProcedureValue); ok { + if len(value.return_types) > 0 { + type := value.return_types[0].type + if type == nil { + type = value.return_types[0].default_value + } + ok = internal_resolve_type_expression(ast_context, type, out) + return ok + } + } } + return ok case ^Deref_Expr: ok := internal_resolve_type_expression(ast_context, v.expr, out) out.pointers -= 1 diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 52dca76..8d5f461 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5642,6 +5642,39 @@ ast_hover_named_proc_arg_hover :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "foo.bar: f32") } + +@(test) +ast_hover_unary_function_call :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + foo :: proc() -> int {} + + main :: proc() { + b{*}ar := -foo() + } + `, + } + test.expect_hover(t, &source, "test.bar: int") +} + +@(test) +ast_hover_unary_overload_function_call :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + foo_int :: proc() -> int {} + foo_string :: proc(s: string) -> string {} + foo :: proc { + foo_int, + foo_string, + } + + main :: proc() { + b{*}ar := -foo() + } + `, + } + test.expect_hover(t, &source, "test.bar: int") +} /* Waiting for odin fix |