diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-09-11 09:01:05 +0100 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-09-12 22:52:23 +0100 |
| commit | 03c363300fd829f3a656c6a9854a9c9720c9b3f1 (patch) | |
| tree | 9cf60f26f2d44e9527fac310102fdb80e085d100 /lib/std | |
| parent | 0001f91e4e1e51cd64cdd5c0a21451c8bad67233 (diff) | |
| download | zig-03c363300fd829f3a656c6a9854a9c9720c9b3f1.tar.gz zig-03c363300fd829f3a656c6a9854a9c9720c9b3f1.zip | |
AstGen: do not allow unlabeled `break` to exit a labeled switch
`break`ing from something which isn't a loop should always be opt-in.
This was a bug in #21257.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/zig/AstGen.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 79ab85f6db..c00ea3ff0f 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -7811,9 +7811,7 @@ fn switchExpr( const switch_block = try parent_gz.makeBlockInst(switch_tag, node); if (switch_full.label_token) |label_token| { - block_scope.break_block = switch_block.toOptional(); block_scope.continue_block = switch_block.toOptional(); - // `break_result_info` already set above block_scope.continue_result_info = .{ .rl = if (any_payload_is_ref) .{ .ref_coerced_ty = raw_operand_ty_ref } @@ -7825,6 +7823,8 @@ fn switchExpr( .token = label_token, .block_inst = switch_block, }; + // `break` can target this via `label.block_inst` + // `break_result_info` already set by `setBreakResultInfo` } // We re-use this same scope for all cases, including the special prong, if any. |
