authorgravatar for 114923809+amp-59@users.noreply.github.comamp-59 <114923809+amp-59@users.noreply.github.com> 2023-12-29 11:42:44+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-12-29 11:42:44+00:00
log27d4bf753467894836e960bced73740c95e61db8
tree27e6467784cb9cff21ed81c7209a92b38aa7699e
parentb0dba4680012e47ffc99f87bab4b53a976cb8b8e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Sema: Initialise `want_safety` for switch prong child block


2 files changed, 31 insertions(+), 0 deletions(-)

src/Sema.zig+1
...@@ -11806,6 +11806,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -11806,6 +11806,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
11806 .runtime_cond = block.runtime_cond,11806 .runtime_cond = block.runtime_cond,
11807 .runtime_loop = block.runtime_loop,11807 .runtime_loop = block.runtime_loop,
11808 .runtime_index = block.runtime_index,11808 .runtime_index = block.runtime_index,
11809 .want_safety = block.want_safety,
11809 .error_return_trace_index = block.error_return_trace_index,11810 .error_return_trace_index = block.error_return_trace_index,
11810 };11811 };
11811 const merges = &child_block.label.?.merges;11812 const merges = &child_block.label.?.merges;
test/cases/inherit_want_safety.zig created+30
...@@ -0,0 +1,30 @@
1pub const panic = @compileError("");
2
3pub export fn entry() usize {
4 @setRuntimeSafety(false);
5 var u: usize = 0;
6 {
7 u += 1;
8 }
9 if (u == 0) {
10 u += 1;
11 }
12 while (u == 0) {
13 u += 1;
14 }
15 for (0..u) |_| {
16 u += 1;
17 }
18 defer {
19 u += 1;
20 }
21 switch (u) {
22 else => {
23 u += 1;
24 },
25 }
26 return u;
27}
28
29// compile
30// output_mode=Obj