Forbid labelled or-branch expressions within defer

This commit is contained in:
Feoramund
2024-09-19 05:55:30 -04:00
parent 0ca5e70c7d
commit acbf5c8d97

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;