| author | |
| committer | |
| log | b4e40cb59a4d8ee498a0ae5b892bb5907745dc1e |
| tree | 52752524a9944de937e76c7d27033aad52d9516b |
| parent | fd4c5f54f05c598c83188409afffea37d4334949 |
| signature |
2 files changed, 15 insertions(+), 0 deletions(-)
src/ir.cpp+1| ... | ... | @@ -10399,6 +10399,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10399 | 10399 | |
| 10400 | 10400 | if (prev_type->id == ZigTypeIdNull) { |
| 10401 | 10401 | prev_inst = cur_inst; |
| 10402 | any_are_null = true; | |
| 10402 | 10403 | continue; |
| 10403 | 10404 | } |
| 10404 | 10405 |
test/stage1/behavior/cast.zig+14| ... | ... | @@ -482,3 +482,17 @@ test "@intCast to u0 and use the result" { |
| 482 | 482 | S.doTheTest(0, 1, 0); |
| 483 | 483 | comptime S.doTheTest(0, 1, 0); |
| 484 | 484 | } |
| 485 | ||
| 486 | test "peer type resolution: unreachable, null, slice" { | |
| 487 | const S = struct { | |
| 488 | fn doTheTest(num: usize, word: []const u8) void { | |
| 489 | const result = switch (num) { | |
| 490 | 0 => null, | |
| 491 | 1 => word, | |
| 492 | else => unreachable, | |
| 493 | }; | |
| 494 | expect(mem.eql(u8, result.?, "hi")); | |
| 495 | } | |
| 496 | }; | |
| 497 | S.doTheTest(1, "hi"); | |
| 498 | } |