blob: d71dc426f95031f82fad636e719efce8afca2d09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
const expect = @import("std").testing.expect;
const builtin = @import("builtin");
const PrefixOp = union(enum) {
Return,
AddrOf: Value,
};
const Value = struct {
align_expr: ?u32,
};
test "optional if after an if in a switch prong of a switch with 2 prongs in an else" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try foo(false, true);
}
fn foo(a: bool, b: bool) !void {
var prefix_op = PrefixOp{
.AddrOf = Value{ .align_expr = 1234 },
};
if (a) {} else {
switch (prefix_op) {
PrefixOp.AddrOf => |addr_of_info| {
if (b) {}
if (addr_of_info.align_expr) |align_expr| {
try expect(align_expr == 1234);
}
},
PrefixOp.Return => {},
}
}
}
|