diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-19 05:55:30 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-19 05:59:37 -0400 |
| commit | acbf5c8d9775f66de69206b89390f2f966b53d73 (patch) | |
| tree | 3e7002e512af45f3135be404b907e52fa1776890 /src | |
| parent | 0ca5e70c7dd5d0259c4624894fcb2957f9de1456 (diff) | |
Forbid labelled or-branch expressions within `defer`
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 4 |
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; |