diff --git a/src/Sema.zig b/src/Sema.zig index f54966f33f..d99e7827be 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -11806,6 +11806,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r .runtime_cond = block.runtime_cond, .runtime_loop = block.runtime_loop, .runtime_index = block.runtime_index, + .want_safety = block.want_safety, .error_return_trace_index = block.error_return_trace_index, }; const merges = &child_block.label.?.merges; diff --git a/test/cases/inherit_want_safety.zig b/test/cases/inherit_want_safety.zig new file mode 100644 index 0000000000..6a70e603a6 --- /dev/null +++ b/test/cases/inherit_want_safety.zig @@ -0,0 +1,30 @@ +pub const panic = @compileError(""); + +pub export fn entry() usize { + @setRuntimeSafety(false); + var u: usize = 0; + { + u += 1; + } + if (u == 0) { + u += 1; + } + while (u == 0) { + u += 1; + } + for (0..u) |_| { + u += 1; + } + defer { + u += 1; + } + switch (u) { + else => { + u += 1; + }, + } + return u; +} + +// compile +// output_mode=Obj