From acbf5c8d9775f66de69206b89390f2f966b53d73 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Thu, 19 Sep 2024 05:55:30 -0400 Subject: [PATCH] Forbid labelled or-branch expressions within `defer` --- src/check_expr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 6776094bf..fc1aa62e6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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;