mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-09 22:32:13 -04:00
fix: reject the use of labels as expressions
This commit is contained in:
1 parent
c5e58ad05a
commit
39cbaf0494
3 files changed
+33
No files matched your search
@@ -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