| 1 | #todo "passes, but prints errors" |
| 2 | #skip x86_64-linux-none-baseline-whole-selfhosted-new-nopic |
| 3 | #skip x86_64-linux-none-baseline-whole-selfhosted-new-pic |
| 4 | #skip x86_64-linux-none-baseline-incremental-selfhosted-new-nopic |
| 5 | #skip x86_64-linux-none-baseline-incremental-selfhosted-new-pic |
| 6 | |
| 7 | #exe { |
| 8 | --name errors |
| 9 | -Mroot=errors.zig |
| 10 | #} |
| 11 | |
| 12 | #write errors.zig { |
| 13 | const Errors = struct { |
| 14 | const Zero = error{}; |
| 15 | const One = Zero || error{One}; |
| 16 | const Two = One || error{Two}; |
| 17 | const Three = Two || error{Three}; |
| 18 | |
| 19 | one: One = error.One, |
| 20 | two: Two = error.Two, |
| 21 | three: Three = error.Three, |
| 22 | any: anyerror = error.Any, |
| 23 | any_void: anyerror!void = error.NotVoid, |
| 24 | any_u32: One!u32 = 42, |
| 25 | }; |
| 26 | fn testErrors(errors: Errors) void { |
| 27 | _ = errors; |
| 28 | } |
| 29 | pub fn main() void { |
| 30 | testErrors(.{}); |
| 31 | } |
| 32 | #} |
| 33 | #update |
| 34 | #check lldb { |
| 35 | (lldb) breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;' |
| 36 | Breakpoint 1: where = errors`errors.testErrors + #... at errors.zig:16:1, address = 0x#... |
| 37 | (lldb) process launch |
| 38 | Process #... launched: '#.../errors' (#...) |
| 39 | Process #... stopped |
| 40 | * thread #1, name = 'errors', stop reason = breakpoint 1.1 |
| 41 | frame #0: errors`errors.testErrors(errors=Errors @ 0x#...) at errors.zig:16:1 |
| 42 | (lldb) expression --show-types -- Errors |
| 43 | (type) $0 = struct { |
| 44 | (type) Zero = error {} |
| 45 | (type) One = error { |
| 46 | (error{One}) One = error.One |
| 47 | } |
| 48 | (type) Two = error { |
| 49 | (error{One,Two}) One = error.One |
| 50 | (error{One,Two}) Two = error.Two |
| 51 | } |
| 52 | (type) Three = error { |
| 53 | (error{One,Three,Two}) One = error.One |
| 54 | (error{One,Three,Two}) Two = error.Two |
| 55 | (error{One,Three,Two}) Three = error.Three |
| 56 | } |
| 57 | } |
| 58 | (lldb) frame variable --show-all-children --show-types -- errors |
| 59 | (root.errors.Errors) errors = { |
| 60 | (error{One}) .one = error.One |
| 61 | (error{One,Two}) .two = error.Two |
| 62 | (error{One,Three,Two}) .three = error.Three |
| 63 | (anyerror) .any = error.Any |
| 64 | (anyerror!void) .any_void = { |
| 65 | (anyerror) .error = error.NotVoid |
| 66 | } |
| 67 | (error{One}!u32) .any_u32 = { |
| 68 | (u32) .value = 42 |
| 69 | } |
| 70 | } |
| 71 | (lldb) breakpoint delete --force 1 |
| 72 | 1 breakpoints deleted; 0 breakpoint locations disabled. |
| 73 | #} |