Skip to content

Commit

Permalink
Merge pull request #4271 from Feoramund/forbid-defer-orbreak
Browse files Browse the repository at this point in the history
Forbid labelled or-branch expressions within `defer`
  • Loading branch information
laytan authored Sep 19, 2024
2 parents d560dad + acbf5c8 commit a52b1e0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/check_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9131,6 +9131,10 @@ gb_internal ExprKind check_or_branch_expr(CheckerContext *c, Operand *o, Ast *no
}

if (label != nullptr) {
if (c->in_defer) {
error(label, "A labelled '%.*s' cannot be used within a 'defer'", LIT(name));
return Expr_Expr;
}
if (label->kind != Ast_Ident) {
error(label, "A branch statement's label name must be an identifier");
return Expr_Expr;
Expand Down

0 comments on commit a52b1e0

Please sign in to comment.