master
1fn f(b: bool) void {
2 const x: i32 = if (b) h: {
3 break :h 1;
4 };
5 _ = x;
6}
7fn g(b: bool) void {
8 const y = if (b) h: {
9 break :h @as(i32, 1);
10 };
11 _ = y;
12}
13fn h() void {
14 // https://github.com/ziglang/zig/issues/12743
15 const T = struct { oh_no: *u32 };
16 var x: T = if (false) {};
17 _ = &x;
18}
19fn k(b: bool) void {
20 // block_ptr case
21 const T = struct { oh_no: u32 };
22 var x = if (b) blk: {
23 break :blk if (false) T{ .oh_no = 2 };
24 } else T{ .oh_no = 1 };
25 _ = &x;
26}
27export fn entry() void {
28 f(true);
29 g(true);
30 h();
31 k(true);
32}
33// error
34//
35// :2:20: error: expected type 'i32', found 'void'
36// :8:15: error: incompatible types: 'i32' and 'void'
37// :8:25: note: type 'i32' here
38// :16:16: error: expected type 'tmp.h.T', found 'void'
39// :15:15: note: struct declared here
40// :22:13: error: incompatible types: 'void' and 'tmp.k.T'
41// :22:25: note: type 'void' here
42// :24:13: note: type 'tmp.k.T' here