| ... | @@ -387,18 +387,13 @@ fn decl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index { | ... | @@ -387,18 +387,13 @@ fn decl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index { |
| 387 | .type_function => { | 387 | .type_function => { |
| 388 | const node_tags = ast.nodes.items(.tag); | 388 | const node_tags = ast.nodes.items(.tag); |
| 389 | | 389 | |
| 390 | // Find the return statement | 390 | // If the type function returns a reference to another type function, get the fields from there |
| | 391 | if (decl.get_type_fn_return_type_fn()) |function_decl| { |
| | 392 | return decl_fields_fallible(function_decl); |
| | 393 | } |
| | 394 | // If the type function returns a container, such as a `struct`, read that container's fields |
| 391 | if (decl.get_type_fn_return_expr()) |return_expr| { | 395 | if (decl.get_type_fn_return_expr()) |return_expr| { |
| 392 | switch (node_tags[return_expr]) { | 396 | switch (node_tags[return_expr]) { |
| 393 | .call, .call_comma, .call_one, .call_one_comma => { | | |
| 394 | const node_data = ast.nodes.items(.data); | | |
| 395 | const function = node_data[return_expr].lhs; | | |
| 396 | const token = ast.nodes.items(.main_token)[function]; | | |
| 397 | const name = ast.tokenSlice(token); | | |
| 398 | if (decl.lookup(name)) |function_decl| { | | |
| 399 | return decl_fields_fallible(function_decl); | | |
| 400 | } | | |
| 401 | }, | | |
| 402 | .container_decl, .container_decl_trailing, .container_decl_two, .container_decl_two_trailing, .container_decl_arg, .container_decl_arg_trailing => { | 397 | .container_decl, .container_decl_trailing, .container_decl_two, .container_decl_two_trailing, .container_decl_arg, .container_decl_arg_trailing => { |
| 403 | return ast_decl_fields_fallible(ast, return_expr); | 398 | return ast_decl_fields_fallible(ast, return_expr); |
| 404 | }, | 399 | }, |