diff options
| -rw-r--r-- | src/server/locals.odin | 6 | ||||
| -rw-r--r-- | tests/hover_test.odin | 54 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/server/locals.odin b/src/server/locals.odin index a88a6d7..edebd85 100644 --- a/src/server/locals.odin +++ b/src/server/locals.odin @@ -285,6 +285,12 @@ get_generic_assignment :: proc( append(results, b) } + case ^Unary_Expr: + append(results, value) + if n, ok := v.expr.derived.(^Type_Assertion); ok { + b := make_bool_ast(ast_context, n.type.pos, n.type.end) + append(results, b) + } case ^Ternary_If_Expr: get_generic_assignment(file, v.x, ast_context, results, calls, flags, is_mutable) case ^Ternary_When_Expr: diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 06d3dce..81c732a 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5716,6 +5716,60 @@ ast_hover_bitshift_integer_type :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.bar: int") } + +@(test) +ast_hover_type_assertion_unary_value :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: union { + int, + f64, + } + + main :: proc() { + foo := Foo(0.0) + i{*} := &foo.(int) + } + `, + } + test.expect_hover(t, &source, "test.i: ^int") +} + +@(test) +ast_hover_type_assertion_unary_value_value :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: union { + int, + f64, + } + + main :: proc() { + foo := Foo(0.0) + i{*}, ok := &foo.(int) + } + `, + } + test.expect_hover(t, &source, "test.i: ^int") +} + +@(test) +ast_hover_type_assertion_unary_value_ok :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: union { + int, + f64, + } + + main :: proc() { + foo := Foo(0.0) + i, ok{*} := &foo.(int) + } + `, + } + test.expect_hover(t, &source, "test.ok: bool") +} /* Waiting for odin fix |