mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 09:44:26 +00:00
fix: reject the use of labels as expressions
This commit is contained in:
@@ -12291,6 +12291,14 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast
|
||||
|
||||
case_ast_node(i, Ident, node);
|
||||
check_ident(c, o, node, nullptr, type_hint, false);
|
||||
{
|
||||
Entity *entity = node->Ident.entity;
|
||||
if (entity != nullptr && entity->kind == Entity_Label) {
|
||||
String name = entity->token.string;
|
||||
error(node, "'%.*s' is a label and cannot be used as an expression", LIT(name));
|
||||
o->mode = Addressing_Invalid;
|
||||
}
|
||||
}
|
||||
case_end;
|
||||
|
||||
case_ast_node(u, Uninit, node);
|
||||
|
||||
Reference in New Issue
Block a user