Commit 07cc2fce2a
Changed files (2)
src
test
behavior
src/Sema.zig
@@ -6972,7 +6972,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
return sema.failWithOwnedErrorMsg(block, msg);
}
- if (special_prong == .@"else") {
+ if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) {
return sema.fail(
block,
special_prong_src,
test/behavior/switch.zig
@@ -610,14 +610,11 @@ test "switch on pointer type" {
}
test "switch on error set with single else" {
- if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
-
const S = struct {
fn doTheTest() !void {
var some: error{Foo} = error.Foo;
try expect(switch (some) {
- else => |a| blk: {
- a catch {};
+ else => blk: {
break :blk true;
},
});