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