mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
Sema: fix single-range switch prong capture (for real this time)
e2338edb47 didn't *quite* do it, the call sites of all switch prong related
functions now have to do their part too and be a little more precise about
what kind of prong they're currently analyzing.
Also removes some unused/unnecessary stuff.
This commit is contained in:
parent
4fcf6507f9
commit
044ba3e0b0
3 changed files with 70 additions and 74 deletions
|
|
@ -1308,7 +1308,7 @@ test "single-item prong in switch on enum has comptime-known capture" {
|
|||
try comptime E.doTheTest(.a);
|
||||
}
|
||||
|
||||
test "single-range switch prong capture" {
|
||||
test "single range switch prong capture" {
|
||||
const S = struct {
|
||||
fn doTheTest(x: u8) !void {
|
||||
switch (x) {
|
||||
|
|
@ -1317,6 +1317,12 @@ test "single-range switch prong capture" {
|
|||
},
|
||||
else => return error.TestFailed,
|
||||
}
|
||||
switch (x) {
|
||||
1...5, 6 => |val| {
|
||||
try expect(val == 2);
|
||||
},
|
||||
else => return error.TestFailed,
|
||||
}
|
||||
}
|
||||
};
|
||||
try S.doTheTest(2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue