| author | |
| committer | |
| log | ff737cc6483e29b2b8c5af1b7c8ed17bb6c70f32 |
| tree | c4d0807fcc7199c84d413849b02cd5bffc806072 |
| parent | b4e40cb59a4d8ee498a0ae5b892bb5907745dc1e |
| signature |
3 files changed, 41 insertions(+), 7 deletions(-)
src/ir.cpp+17-5| ... | ... | @@ -10093,9 +10093,21 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10093 | 10093 | { |
| 10094 | 10094 | Error err; |
| 10095 | 10095 | assert(instruction_count >= 1); |
| 10096 | IrInstruction *prev_inst = instructions[0]; | |
| 10097 | if (type_is_invalid(prev_inst->value.type)) { | |
| 10098 | return ira->codegen->builtin_types.entry_invalid; | |
| 10096 | IrInstruction *prev_inst; | |
| 10097 | size_t i = 0; | |
| 10098 | for (;;) { | |
| 10099 | prev_inst = instructions[i]; | |
| 10100 | if (type_is_invalid(prev_inst->value.type)) { | |
| 10101 | return ira->codegen->builtin_types.entry_invalid; | |
| 10102 | } | |
| 10103 | if (prev_inst->value.type->id == ZigTypeIdUnreachable) { | |
| 10104 | i += 1; | |
| 10105 | if (i == instruction_count) { | |
| 10106 | return prev_inst->value.type; | |
| 10107 | } | |
| 10108 | continue; | |
| 10109 | } | |
| 10110 | break; | |
| 10099 | 10111 | } |
| 10100 | 10112 | ErrorTableEntry **errors = nullptr; |
| 10101 | 10113 | size_t errors_count = 0; |
| ... | ... | @@ -10120,7 +10132,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10120 | 10132 | |
| 10121 | 10133 | bool any_are_null = (prev_inst->value.type->id == ZigTypeIdNull); |
| 10122 | 10134 | bool convert_to_const_slice = false; |
| 10123 | for (size_t i = 1; i < instruction_count; i += 1) { | |
| 10135 | for (; i < instruction_count; i += 1) { | |
| 10124 | 10136 | IrInstruction *cur_inst = instructions[i]; |
| 10125 | 10137 | ZigType *cur_type = cur_inst->value.type; |
| 10126 | 10138 | ZigType *prev_type = prev_inst->value.type; |
| ... | ... | @@ -10139,7 +10151,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10139 | 10151 | } |
| 10140 | 10152 | |
| 10141 | 10153 | if (prev_type->id == ZigTypeIdErrorSet) { |
| 10142 | assert(err_set_type != nullptr); | |
| 10154 | ir_assert(err_set_type != nullptr, prev_inst); | |
| 10143 | 10155 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 10144 | 10156 | if (type_is_global_error_set(err_set_type)) { |
| 10145 | 10157 | continue; |
std/event/fs.zig+1-2| ... | ... | @@ -1290,10 +1290,9 @@ pub fn Watch(comptime V: type) type { |
| 1290 | 1290 | error.FileDescriptorAlreadyPresentInSet => unreachable, |
| 1291 | 1291 | error.OperationCausesCircularLoop => unreachable, |
| 1292 | 1292 | error.FileDescriptorNotRegistered => unreachable, |
| 1293 | error.SystemResources => error.SystemResources, | |
| 1294 | error.UserResourceLimitReached => error.UserResourceLimitReached, | |
| 1295 | 1293 | error.FileDescriptorIncompatibleWithEpoll => unreachable, |
| 1296 | 1294 | error.Unexpected => unreachable, |
| 1295 | else => |e| e, | |
| 1297 | 1296 | }; |
| 1298 | 1297 | await (async channel.put(transformed_err) catch unreachable); |
| 1299 | 1298 | }; |
test/stage1/behavior/cast.zig+23| ... | ... | @@ -496,3 +496,26 @@ test "peer type resolution: unreachable, null, slice" { |
| 496 | 496 | }; |
| 497 | 497 | S.doTheTest(1, "hi"); |
| 498 | 498 | } |
| 499 | ||
| 500 | test "peer type resolution: unreachable, error set, unreachable" { | |
| 501 | const Error = error { | |
| 502 | FileDescriptorAlreadyPresentInSet, | |
| 503 | OperationCausesCircularLoop, | |
| 504 | FileDescriptorNotRegistered, | |
| 505 | SystemResources, | |
| 506 | UserResourceLimitReached, | |
| 507 | FileDescriptorIncompatibleWithEpoll, | |
| 508 | Unexpected, | |
| 509 | }; | |
| 510 | var err = Error.SystemResources; | |
| 511 | const transformed_err = switch (err) { | |
| 512 | error.FileDescriptorAlreadyPresentInSet => unreachable, | |
| 513 | error.OperationCausesCircularLoop => unreachable, | |
| 514 | error.FileDescriptorNotRegistered => unreachable, | |
| 515 | error.SystemResources => error.SystemResources, | |
| 516 | error.UserResourceLimitReached => error.UserResourceLimitReached, | |
| 517 | error.FileDescriptorIncompatibleWithEpoll => unreachable, | |
| 518 | error.Unexpected => unreachable, | |
| 519 | }; | |
| 520 | expect(transformed_err == error.SystemResources); | |
| 521 | } |