aboutsummaryrefslogtreecommitdiff
path: root/lib/docs
diff options
context:
space:
mode:
authorschtvn <schteven.codes@gmail.com>2025-02-17 22:30:49 -0800
committerschtvn <schteven.codes@gmail.com>2025-02-17 22:30:49 -0800
commit9e925a7acce05a69a26fe186acffb47dca326a11 (patch)
tree535f520972be339efdc8bd9ca7f8f9ad8f584c24 /lib/docs
parent5a313192e668501f7ab04b2f1d55b92a3cf33a0e (diff)
downloadzig-9e925a7acce05a69a26fe186acffb47dca326a11.tar.gz
zig-9e925a7acce05a69a26fe186acffb47dca326a11.zip
Clean up duplicate code in decl_fields_fallible
Diffstat (limited to 'lib/docs')
-rw-r--r--lib/docs/wasm/main.zig15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/docs/wasm/main.zig b/lib/docs/wasm/main.zig
index d9dedcca8d..09d40a9e2a 100644
--- a/lib/docs/wasm/main.zig
+++ b/lib/docs/wasm/main.zig
@@ -387,18 +387,13 @@ fn decl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index {
.type_function => {
const node_tags = ast.nodes.items(.tag);
- // Find the return statement
+ // If the type function returns a reference to another type function, get the fields from there
+ if (decl.get_type_fn_return_type_fn()) |function_decl| {
+ return decl_fields_fallible(function_decl);
+ }
+ // If the type function returns a container, such as a `struct`, read that container's fields
if (decl.get_type_fn_return_expr()) |return_expr| {
switch (node_tags[return_expr]) {
- .call, .call_comma, .call_one, .call_one_comma => {
- const node_data = ast.nodes.items(.data);
- const function = node_data[return_expr].lhs;
- const token = ast.nodes.items(.main_token)[function];
- const name = ast.tokenSlice(token);
- if (decl.lookup(name)) |function_decl| {
- return decl_fields_fallible(function_decl);
- }
- },
.container_decl, .container_decl_trailing, .container_decl_two, .container_decl_two_trailing, .container_decl_arg, .container_decl_arg_trailing => {
return ast_decl_fields_fallible(ast, return_expr);
},