mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
for in iteration of Enum Type (request from issue #58)
This commit is contained in:
+14
-2
@@ -920,9 +920,21 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
|
||||
idx = t_int;
|
||||
} else {
|
||||
Operand operand = {Addressing_Invalid};
|
||||
check_expr(c, &operand, rs->expr);
|
||||
check_expr_or_type(c, &operand, rs->expr);
|
||||
|
||||
if (operand.mode != Addressing_Invalid) {
|
||||
if (operand.mode == Addressing_Type) {
|
||||
if (!is_type_enum(operand.type)) {
|
||||
gbString t = type_to_string(operand.type);
|
||||
error_node(operand.expr, "Cannot iterate over the type `%s`", t);
|
||||
gb_string_free(t);
|
||||
goto skip_expr;
|
||||
} else {
|
||||
val = operand.type;
|
||||
idx = t_int;
|
||||
add_type_info_type(c, operand.type);
|
||||
goto skip_expr;
|
||||
}
|
||||
} else if (operand.mode != Addressing_Invalid) {
|
||||
Type *t = base_type(type_deref(operand.type));
|
||||
switch (t->kind) {
|
||||
case Type_Basic:
|
||||
|
||||
Reference in New Issue
Block a user