| author | |
| committer | |
| log | 5fc5e4fbe04ccbe5ea37b07c1153a7c5bd2b4346 |
| tree | 1621f97c37307f64f7ef730384a209f8c52fbac5 |
| parent | 9d66481e3df35b54275373a685e765a4bcebd712 |
2 files changed, 14 insertions(+), 0 deletions(-)
src/Sema.zig+2| ... | ... | @@ -11646,6 +11646,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11646 | 11646 | cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); |
| 11647 | 11647 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); |
| 11648 | 11648 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 11649 | ||
| 11650 | if (item.compareScalar(.eq, item_last, operand_ty, mod)) break; | |
| 11649 | 11651 | } |
| 11650 | 11652 | } |
| 11651 | 11653 |
test/behavior/switch.zig+12| ... | ... | @@ -785,3 +785,15 @@ test "switch pointer capture peer type resolution" { |
| 785 | 785 | try expectEqual(U{ .a = 111 }, ua); |
| 786 | 786 | try expectEqual(U{ .b = 222 }, ub); |
| 787 | 787 | } |
| 788 | ||
| 789 | test "inline switch range that includes the maximum value of the switched type" { | |
| 790 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | |
| 791 | ||
| 792 | const inputs: [3]u8 = .{ 0, 254, 255 }; | |
| 793 | for (inputs) |input| { | |
| 794 | switch (input) { | |
| 795 | inline 254...255 => |val| try expectEqual(input, val), | |
| 796 | else => |val| try expectEqual(input, val), | |
| 797 | } | |
| 798 | } | |
| 799 | } |