Merge pull request #4271 from Feoramund/forbid-defer-orbreak

Forbid labelled or-branch expressions within `defer`
This commit is contained in:
Laytan
2024-09-19 13:25:28 +02:00
committed by GitHub
+4
View File
@@ -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;