| ... | ... | @@ -205,3 +205,23 @@ fn testSwitchHandleAllCasesRange(x: u8) -> u8 { |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | test "switch all prongs unreachable" { |
| 209 | testAllProngsUnreachable(); |
| 210 | comptime testAllProngsUnreachable(); |
| 211 | } |
| 212 | |
| 213 | fn testAllProngsUnreachable() { |
| 214 | assert(switchWithUnreachable(1) == 2); |
| 215 | assert(switchWithUnreachable(2) == 10); |
| 216 | } |
| 217 | |
| 218 | fn switchWithUnreachable(x: i32) -> i32 { |
| 219 | while (true) { |
| 220 | switch (x) { |
| 221 | 1 => return 2, |
| 222 | 2 => break, |
| 223 | else => continue, |
| 224 | } |
| 225 | } |
| 226 | return 10; |
| 227 | } |