AstGen: clear rl_ty_inst in setBreakResultLoc if one is not provided

This commit is contained in:
Veikka Tuominen
2022-03-28 12:23:19 +03:00
committed by Andrew Kelley
parent 3c4ac47e00
commit a415fe0bc0
2 changed files with 26 additions and 2 deletions

View File

@@ -854,3 +854,24 @@ test "labeled block implicitly ends in a break" {
if (a) break :blk;
}
}
test "catch in block has correct result location" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
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;
const S = struct {
fn open() error{A}!@This() {
return @This(){};
}
fn foo(_: @This()) u32 {
return 1;
}
};
const config_h_text: u32 = blk: {
var dir = S.open() catch unreachable;
break :blk dir.foo();
};
try expect(config_h_text == 1);
}