Procházet zdrojové kódy

Forbid labelled or-branch expressions within `defer`

Feoramund před 1 rokem
rodič
revize
acbf5c8d97
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 4 0
      src/check_expr.cpp

+ 4 - 0
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;