| ... | @@ -2276,7 +2276,7 @@ fn continueExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) | ... | @@ -2276,7 +2276,7 @@ fn continueExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) |
| 2276 | if (try astgen.tokenIdentEql(label.token, break_label)) { | 2276 | if (try astgen.tokenIdentEql(label.token, break_label)) { |
| 2277 | switch (gen_zir.continue_target) { | 2277 | switch (gen_zir.continue_target) { |
| 2278 | .none => { | 2278 | .none => { |
| 2279 | return astgen.failNode(node, "continue cannot target labeled block", .{}); | 2279 | return astgen.failNode(node, "continue outside of loop or labeled switch expression", .{}); |
| 2280 | }, | 2280 | }, |
| 2281 | .@"break" => if (opt_rhs != .none) { | 2281 | .@"break" => if (opt_rhs != .none) { |
| 2282 | return astgen.failNode(node, "cannot continue loop with operand", .{}); | 2282 | return astgen.failNode(node, "cannot continue loop with operand", .{}); |
| ... | @@ -6803,12 +6803,11 @@ fn whileExpr( | ... | @@ -6803,12 +6803,11 @@ fn whileExpr( |
| 6803 | break :s &else_scope.base; | 6803 | break :s &else_scope.base; |
| 6804 | } | 6804 | } |
| 6805 | }; | 6805 | }; |
| 6806 | // Remove label and forbid unlabeled control flow to this scope so that | 6806 | // Disallow unlabeled control flow to this scope so that bare `continue` |
| 6807 | // `continue` and `break` control flow apply to outer loops; not this one. | 6807 | // and `break` control flow apply to outer loops; not this one. |
| 6808 | loop_scope.label = null; | 6808 | // Also disallow `continue` targeting the loop label. |
| 6809 | loop_scope.allow_unlabeled_control_flow = false; | 6809 | loop_scope.allow_unlabeled_control_flow = false; |
| 6810 | loop_scope.continue_target = undefined; | 6810 | loop_scope.continue_target = .none; |
| 6811 | loop_scope.break_target = undefined; | | |
| 6812 | const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); | 6811 | const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); |
| 6813 | if (is_statement) { | 6812 | if (is_statement) { |
| 6814 | _ = try addEnsureResult(&else_scope, else_result, else_node); | 6813 | _ = try addEnsureResult(&else_scope, else_result, else_node); |
| ... | @@ -7093,12 +7092,11 @@ fn forExpr( | ... | @@ -7093,12 +7092,11 @@ fn forExpr( |
| 7093 | | 7092 | |
| 7094 | if (for_full.ast.else_expr.unwrap()) |else_node| { | 7093 | if (for_full.ast.else_expr.unwrap()) |else_node| { |
| 7095 | const sub_scope = &else_scope.base; | 7094 | const sub_scope = &else_scope.base; |
| 7096 | // Remove label and forbid unlabeled control flow to this scope so that | 7095 | // Disallow unlabeled control flow to this scope so that bare `continue` |
| 7097 | // `continue` and `break` control flow apply to outer loops; not this one. | 7096 | // and `break` control flow apply to outer loops; not this one. |
| 7098 | loop_scope.label = null; | 7097 | // Also disallow `continue` targeting the loop label. |
| 7099 | loop_scope.allow_unlabeled_control_flow = false; | 7098 | loop_scope.allow_unlabeled_control_flow = false; |
| 7100 | loop_scope.continue_target = undefined; | 7099 | loop_scope.continue_target = .none; |
| 7101 | loop_scope.break_target = undefined; | | |
| 7102 | const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); | 7100 | const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); |
| 7103 | if (is_statement) { | 7101 | if (is_statement) { |
| 7104 | _ = try addEnsureResult(&else_scope, else_result, else_node); | 7102 | _ = try addEnsureResult(&else_scope, else_result, else_node); |