authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-01-03 18:19:21+01:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-01-03 18:20:06+01:00
log755f50a986f429f7395848e883e154c3ab6c3f26
tree0e89b157b00a088919d08d2ea25b6a2fe6ef46bf
parentabd005f302ee81213b3f3a97a08d025cb3b1ecee

autodoc: restore generic function functionality

latest changes to zir encoding broke simple return type detection

1 files changed, 20 insertions(+), 6 deletions(-)

src/Autodoc.zig+20-6
......@@ -3798,7 +3798,7 @@ fn analyzeFancyFunction(
37983798 file,
37993799 scope,
38003800 parent_src,
3801 fn_info.body[fn_info.body.len - 1],
3801 fn_info.body[0],
38023802 );
38033803 } else {
38043804 break :blk null;
......@@ -3936,7 +3936,7 @@ fn analyzeFunction(
39363936 file,
39373937 scope,
39383938 parent_src,
3939 fn_info.body[fn_info.body.len - 1],
3939 fn_info.body[0],
39403940 );
39413941 } else {
39423942 break :blk null;
......@@ -3977,11 +3977,25 @@ fn getGenericReturnType(
39773977 file: *File,
39783978 scope: *Scope,
39793979 parent_src: SrcLocInfo, // function decl line
3980 body_end: usize,
3980 body_main_block: usize,
39813981) !DocData.Expr {
3982 // TODO: compute the correct line offset
3983 const wr = try self.walkInstruction(file, scope, parent_src, body_end - 3, false);
3984 return wr.expr;
3982 const tags = file.zir.instructions.items(.tag);
3983 const data = file.zir.instructions.items(.data);
3984
3985 // We expect `body_main_block` to be the first instruction
3986 // inside the function body, and for it to be a block instruction.
3987 const pl_node = data[body_main_block].pl_node;
3988 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
3989 const maybe_ret_node = file.zir.extra[extra.end..][extra.data.body_len - 4];
3990 switch (tags[maybe_ret_node]) {
3991 .ret_node, .ret_load => {
3992 const wr = try self.walkInstruction(file, scope, parent_src, maybe_ret_node, false);
3993 return wr.expr;
3994 },
3995 else => {
3996 return DocData.Expr{ .comptimeExpr = 0 };
3997 },
3998 }
39853999}
39864000
39874001fn collectUnionFieldInfo(