blob: 72084188d72f164be30228a720f7b6a5d6ddc9e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
const builtin = @import("builtin");
fn retOpt() ?u32 {
return null;
}
test "breaking from a loop in an if statement" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var cond = true;
const opt = while (cond) {
if (retOpt()) |opt| {
break opt;
}
break 1;
} else 2;
_ = opt;
}
|