aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-09-19 13:25:28 +0200
committerGitHub <noreply@github.com>2024-09-19 13:25:28 +0200
commita52b1e03219034d13f8f1f1335b54c0678cc7822 (patch)
tree4d97ba4e82a88ecedeeef9630cc283a913fa80c1 /src/check_expr.cpp
parentd560dad0d84f2a2c830810bb44b8e250a494511f (diff)
parentacbf5c8d9775f66de69206b89390f2f966b53d73 (diff)
Merge pull request #4271 from Feoramund/forbid-defer-orbreak
Forbid labelled or-branch expressions within `defer`
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp4
1 files changed, 4 insertions, 0 deletions
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;