2017-12-14 14:07:23 +08:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
|
|
|
|
const PrefixOp = union(enum) {
|
|
|
|
Return,
|
|
|
|
AddrOf: Value,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Value = struct {
|
|
|
|
align_expr: ?u32,
|
|
|
|
};
|
|
|
|
|
2018-06-10 11:42:14 +08:00
|
|
|
test "optional if after an if in a switch prong of a switch with 2 prongs in an else" {
|
2017-12-14 14:07:23 +08:00
|
|
|
foo(false, true);
|
|
|
|
}
|
|
|
|
|
2018-01-25 17:10:11 +08:00
|
|
|
fn foo(a: bool, b: bool) void {
|
2018-05-29 08:23:55 +08:00
|
|
|
var prefix_op = PrefixOp{
|
|
|
|
.AddrOf = Value{ .align_expr = 1234 },
|
2018-05-01 08:35:54 +08:00
|
|
|
};
|
|
|
|
if (a) {} else {
|
2017-12-14 14:07:23 +08:00
|
|
|
switch (prefix_op) {
|
|
|
|
PrefixOp.AddrOf => |addr_of_info| {
|
2018-05-01 08:35:54 +08:00
|
|
|
if (b) {}
|
2017-12-14 14:07:23 +08:00
|
|
|
if (addr_of_info.align_expr) |align_expr| {
|
|
|
|
assert(align_expr == 1234);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PrefixOp.Return => {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|