| author | |
| committer | |
| log | 3919afcad26d2359efe52f98cd4f2f0573527369 |
| tree | 3a28825c55dde7d7f086af5285552ee2f5234299 |
| parent | 2c697e50db36e4f9c0af8b1a9d357deeb8f80026 |
closes #7652 files changed, 26 insertions(+), 1 deletions(-)
src/ir.cpp+1-1| ... | @@ -7279,7 +7279,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod | ... | @@ -7279,7 +7279,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 7279 | prev_inst = cur_inst; | 7279 | prev_inst = cur_inst; |
| 7280 | } | 7280 | } |
| 7281 | 7281 | ||
| 7282 | TypeTableEntry *prev_err_set_type = prev_type->data.error_union.err_set_type; | 7282 | TypeTableEntry *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type; |
| 7283 | TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type; | 7283 | TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type; |
| 7284 | 7284 | ||
| 7285 | if (!resolve_inferred_error_set(ira, prev_err_set_type, cur_inst->source_node)) { | 7285 | if (!resolve_inferred_error_set(ira, prev_err_set_type, cur_inst->source_node)) { |
test/cases/error.zig+25| ... | @@ -150,3 +150,28 @@ fn testErrToIntWithOnePossibleValue(x: error{A}, comptime value: u32) void { | ... | @@ -150,3 +150,28 @@ fn testErrToIntWithOnePossibleValue(x: error{A}, comptime value: u32) void { |
| 150 | @compileError("bad"); | 150 | @compileError("bad"); |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
| 153 | |||
| 154 | test "error union peer type resolution" { | ||
| 155 | testErrorUnionPeerTypeResolution(1); | ||
| 156 | comptime testErrorUnionPeerTypeResolution(1); | ||
| 157 | } | ||
| 158 | |||
| 159 | fn testErrorUnionPeerTypeResolution(x: i32) void { | ||
| 160 | const y = switch (x) { | ||
| 161 | 1 => bar_1(), | ||
| 162 | 2 => baz_1(), | ||
| 163 | else => quux_1(), | ||
| 164 | }; | ||
| 165 | } | ||
| 166 | |||
| 167 | fn bar_1() error { | ||
| 168 | return error.A; | ||
| 169 | } | ||
| 170 | |||
| 171 | fn baz_1() !i32 { | ||
| 172 | return error.B; | ||
| 173 | } | ||
| 174 | |||
| 175 | fn quux_1() !i32 { | ||
| 176 | return error.C; | ||
| 177 | } |