diff options
| -rw-r--r-- | src/server/analysis.odin | 4 | ||||
| -rw-r--r-- | tests/hover_test.odin | 28 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index d11d8b0..570a035 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1943,6 +1943,10 @@ resolve_slice_expression :: proc(ast_context: ^AstContext, slice_expr: ^ast.Slic case SymbolDynamicArrayValue: expr = v.expr case SymbolMultiPointerValue: + // Slicing multi-pointer behaviour outlined here: https://odin-lang.org/docs/overview/#multi-pointers + if slice_expr.high == nil { + return symbol, true + } expr = v.expr case SymbolUntypedValue: if v.type == .String { diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 51e53bf..37d0362 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -4202,7 +4202,7 @@ ast_hover_untyped_string_index :: proc(t: ^testing.T) { } @(test) -ast_hover_multi_pointer_slice_range :: proc(t: ^testing.T) { +ast_hover_multi_pointer_slice_end_range :: proc(t: ^testing.T) { source := test.Source { main = `package test main :: proc() { @@ -4215,6 +4215,32 @@ ast_hover_multi_pointer_slice_range :: proc(t: ^testing.T) { } @(test) +ast_hover_multi_pointer_slice_start_range :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + main :: proc() { + foo: [^]int + b{*}ar := foo[1:] + } + `, + } + test.expect_hover(t, &source, "test.bar: [^]int") +} + +@(test) +ast_hover_multi_pointer_slice_no_range :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + main :: proc() { + foo: [^]int + b{*}ar := foo[:] + } + `, + } + test.expect_hover(t, &source, "test.bar: [^]int") +} + +@(test) ast_hover_binary_expr_with_type :: proc(t: ^testing.T) { source := test.Source { main = `package test |