aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-19 05:55:30 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-19 05:59:37 -0400
commitacbf5c8d9775f66de69206b89390f2f966b53d73 (patch)
tree3e7002e512af45f3135be404b907e52fa1776890 /src/check_expr.cpp
parent0ca5e70c7dd5d0259c4624894fcb2957f9de1456 (diff)
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;