Commit ec5b751373

dweiller <4678790+dweiller@users.noreply.github.com>
2023-12-30 02:58:35
sema: inherit block want_safety for err switch union
1 parent 69ab687
Changed files (2)
src/Sema.zig
@@ -11292,6 +11292,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
         .runtime_loop = block.runtime_loop,
         .runtime_index = block.runtime_index,
         .error_return_trace_index = block.error_return_trace_index,
+        .want_safety = block.want_safety,
     };
     const merges = &child_block.label.?.merges;
     defer child_block.instructions.deinit(gpa);
test/cases/inherit_want_safety.zig
@@ -23,6 +23,13 @@ pub export fn entry() usize {
             u += 1;
         },
     }
+    if (@as(error{}!usize, u)) |_| {
+        u += 1;
+    } else |e| switch (e) {
+        else => {
+            u += 1;
+        }
+    }
     return u;
 }