aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2025-06-03 21:15:08 +0200
committerGitHub <noreply@github.com>2025-06-03 21:15:08 +0200
commit4fb3c51850eadffe0091dcd297ff284526dca601 (patch)
tree6a4e0d1c767f5ff77e006da04dc43845c7598d7e
parent06b5415a36fd9537873841edd469b577fbdeb6b1 (diff)
parent8bcc43ff70994bcad692075bbe6b14f37ebe8c56 (diff)
Merge pull request #646 from BradLewis/master
Fix proc param with no return display arrow in hover contents
-rw-r--r--src/common/ast.odin7
-rw-r--r--tests/hover_test.odin21
2 files changed, 26 insertions, 2 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index 6031d9d..1d286a5 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -1115,8 +1115,11 @@ build_string_node :: proc(node: ^ast.Node, builder: ^strings.Builder, remove_poi
case ^Proc_Type:
strings.write_string(builder, "proc(")
build_string(n.params, builder, remove_pointers)
- strings.write_string(builder, ") -> ")
- build_string(n.results, builder, remove_pointers)
+ strings.write_string(builder, ")")
+ if n.results != nil {
+ strings.write_string(builder, " -> ")
+ build_string(n.results, builder, remove_pointers)
+ }
case ^Pointer_Type:
if !remove_pointers {
strings.write_string(builder, "^")
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 0c3b750..9f1a9f0 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -354,6 +354,27 @@ ast_hover_proc_group :: proc(t: ^testing.T) {
test.expect_hover(t, &source, "test.add: proc(a, b: int) -> int")
}
+@(test)
+ast_hover_proc_with_proc_parameter :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ a{*}a :: proc(p: proc()) {}
+ `,
+ }
+
+ test.expect_hover(t, &source, "test.aa: proc(p: proc())")
+}
+
+@(test)
+ast_hover_proc_with_proc_parameter_with_return :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ a{*}a :: proc(p: proc() -> int) {}
+ `,
+ }
+
+ test.expect_hover(t, &source, "test.aa: proc(p: proc() -> int)")
+}
/*