| ... | ... | @@ -468,7 +468,7 @@ const DocData = struct { |
| 468 | 468 | child: Expr, |
| 469 | 469 | }, |
| 470 | 470 | ErrorUnion: struct { lhs: Expr, rhs: Expr }, |
| 471 | | // ErrorUnion: struct { name: []const u8 }, |
| 471 | InferredErrorUnion: struct { payload: Expr }, |
| 472 | 472 | ErrorSet: struct { |
| 473 | 473 | name: []const u8, |
| 474 | 474 | fields: ?[]const Field = null, |
| ... | ... | @@ -582,7 +582,7 @@ const DocData = struct { |
| 582 | 582 | typeOf: usize, // index in `exprs` |
| 583 | 583 | typeInfo: usize, // index in `exprs` |
| 584 | 584 | typeOf_peer: []usize, |
| 585 | | errorUnion: usize, // index in `exprs` |
| 585 | errorUnion: usize, // index in `types` |
| 586 | 586 | as: As, |
| 587 | 587 | sizeOf: usize, // index in `exprs` |
| 588 | 588 | bitSizeOf: usize, // index in `exprs` |
| ... | ... | @@ -1929,7 +1929,7 @@ fn walkInstruction( |
| 1929 | 1929 | .comptimeExpr = self.comptime_exprs.items.len, |
| 1930 | 1930 | } }; |
| 1931 | 1931 | try self.comptime_exprs.append(self.arena, .{ |
| 1932 | | .code = "if(banana) 1 else 0", |
| 1932 | .code = "if (...) { ... }", |
| 1933 | 1933 | }); |
| 1934 | 1934 | return res; |
| 1935 | 1935 | }, |
| ... | ... | @@ -2119,6 +2119,7 @@ fn walkInstruction( |
| 2119 | 2119 | inst_index, |
| 2120 | 2120 | self_ast_node_index, |
| 2121 | 2121 | type_slot_index, |
| 2122 | tags[inst_index] == .func_inferred, |
| 2122 | 2123 | ); |
| 2123 | 2124 | |
| 2124 | 2125 | return result; |
| ... | ... | @@ -3416,6 +3417,7 @@ fn analyzeFunction( |
| 3416 | 3417 | inst_index: usize, |
| 3417 | 3418 | self_ast_node_index: usize, |
| 3418 | 3419 | type_slot_index: usize, |
| 3420 | ret_is_inferred_error_set: bool, |
| 3419 | 3421 | ) AutodocErrors!DocData.WalkResult { |
| 3420 | 3422 | const tags = file.zir.instructions.items(.tag); |
| 3421 | 3423 | const data = file.zir.instructions.items(.data); |
| ... | ... | @@ -3522,13 +3524,23 @@ fn analyzeFunction( |
| 3522 | 3524 | else => null, |
| 3523 | 3525 | }; |
| 3524 | 3526 | |
| 3527 | const ret_type: DocData.Expr = blk: { |
| 3528 | if (ret_is_inferred_error_set) { |
| 3529 | const ret_type_slot_index = self.types.items.len; |
| 3530 | try self.types.append(self.arena, .{ |
| 3531 | .InferredErrorUnion = .{ .payload = ret_type_ref }, |
| 3532 | }); |
| 3533 | break :blk .{ .type = ret_type_slot_index }; |
| 3534 | } else break :blk ret_type_ref; |
| 3535 | }; |
| 3536 | |
| 3525 | 3537 | self.ast_nodes.items[self_ast_node_index].fields = param_ast_indexes.items; |
| 3526 | 3538 | self.types.items[type_slot_index] = .{ |
| 3527 | 3539 | .Fn = .{ |
| 3528 | 3540 | .name = "todo_name func", |
| 3529 | 3541 | .src = self_ast_node_index, |
| 3530 | 3542 | .params = param_type_refs.items, |
| 3531 | | .ret = ret_type_ref, |
| 3543 | .ret = ret_type, |
| 3532 | 3544 | .generic_ret = generic_ret, |
| 3533 | 3545 | }, |
| 3534 | 3546 | }; |