| author | |
| committer | |
| log | 79a3dfcfd8c822096ed40fbe6f930d614a8dcb40 |
| tree | d4885241b4f2c9987ce710ad38ea4cb3b01ff259 |
| parent | cde3dd365e1fed806294eddc91700558d2135a64 |
3 files changed, 11 insertions(+), 2 deletions(-)
src/AstGen.zig+2-2| ... | ... | @@ -1691,9 +1691,9 @@ fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) Inn |
| 1691 | 1691 | return Zir.Inst.Ref.unreachable_value; |
| 1692 | 1692 | } |
| 1693 | 1693 | block_gz.break_count += 1; |
| 1694 | const prev_rvalue_rl_count = block_gz.rvalue_rl_count; | |
| 1695 | 1694 | const operand = try expr(parent_gz, parent_scope, block_gz.break_result_loc, rhs); |
| 1696 | const have_store_to_block = block_gz.rvalue_rl_count != prev_rvalue_rl_count; | |
| 1695 | // if list grew as much as rvalue_rl_count, then a break inside operand already saved the store_to_block_ptr | |
| 1696 | const have_store_to_block = block_gz.rvalue_rl_count > block_gz.labeled_store_to_block_ptr_list.items.len; | |
| 1697 | 1697 | |
| 1698 | 1698 | const br = try parent_gz.addBreak(.@"break", block_inst, operand); |
| 1699 | 1699 |
test/behavior.zig+1| ... | ... | @@ -112,6 +112,7 @@ test { |
| 112 | 112 | _ = @import("behavior/bugs/7047.zig"); |
| 113 | 113 | _ = @import("behavior/bugs/7250.zig"); |
| 114 | 114 | _ = @import("behavior/bugs/9584.zig"); |
| 115 | _ = @import("behavior/bugs/9967.zig"); | |
| 115 | 116 | _ = @import("behavior/byteswap.zig"); |
| 116 | 117 | _ = @import("behavior/byval_arg_var.zig"); |
| 117 | 118 | _ = @import("behavior/call_stage1.zig"); |
test/behavior/bugs/9967.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | test "nested breaks to same labeled block" { | |
| 4 | const a = blk: { | |
| 5 | break :blk break :blk @as(u32, 1); | |
| 6 | }; | |
| 7 | try std.testing.expectEqual(a, 1); | |
| 8 | } |