aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-01-05 17:12:43 +0100
committerLoris Cro <kappaloris@gmail.com>2023-01-05 17:12:43 +0100
commit1878bdfbb127321d327ce3cfd8ec148959302b95 (patch)
tree4953a0bd70913cab3710348771bda0883ee325e5 /src
parentc6ea551c7d79195d0b385efdf34f30edf84733d1 (diff)
downloadzig-1878bdfbb127321d327ce3cfd8ec148959302b95.tar.gz
zig-1878bdfbb127321d327ce3cfd8ec148959302b95.zip
autodoc: fix bodyless fn type analysis and rendering
Diffstat (limited to 'src')
-rw-r--r--src/Autodoc.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
index 6f7e15c4f6..fa0b64a929 100644
--- a/src/Autodoc.zig
+++ b/src/Autodoc.zig
@@ -3807,10 +3807,15 @@ fn analyzeFancyFunction(
else => null,
};
+ // if we're analyzing a funcion signature (ie without body), we
+ // actually don't have an ast_node reserved for us, but since
+ // we don't have a name, we don't need it.
+ const src = if (fn_info.body.len == 0) 0 else self_ast_node_index;
+
self.types.items[type_slot_index] = .{
.Fn = .{
.name = "todo_name func",
- .src = self_ast_node_index,
+ .src = src,
.params = param_type_refs.items,
.ret = ret_type_ref,
.generic_ret = generic_ret,
@@ -3955,11 +3960,16 @@ fn analyzeFunction(
} else break :blk ret_type_ref;
};
+ // if we're analyzing a funcion signature (ie without body), we
+ // actually don't have an ast_node reserved for us, but since
+ // we don't have a name, we don't need it.
+ const src = if (fn_info.body.len == 0) 0 else self_ast_node_index;
+
self.ast_nodes.items[self_ast_node_index].fields = param_ast_indexes.items;
self.types.items[type_slot_index] = .{
.Fn = .{
.name = "todo_name func",
- .src = self_ast_node_index,
+ .src = src,
.params = param_type_refs.items,
.ret = ret_type,
.generic_ret = generic_ret,