Merge remote-tracking branch 'origin/master' into llvm15

This commit is contained in:
Andrew Kelley
2022-09-12 16:11:18 -07:00
9 changed files with 261 additions and 148 deletions

View File

@@ -127,3 +127,20 @@ test "errdefer with payload" {
try S.doTheTest();
comptime try S.doTheTest();
}
test "simple else prong doesn't emit an error for unreachable else prong" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
const S = struct {
fn foo() error{Foo}!void {
return error.Foo;
}
};
var a: u32 = 0;
defer a += 1;
S.foo() catch |err| switch (err) {
error.Foo => a += 1,
else => |e| return e,
};
try expect(a == 1);
}