Browse Source

Fix comparison bug of enumerated arrays

gingerBill 4 years ago
parent
commit
bb7bd94b0a
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/llvm_backend.cpp

+ 6 - 2
src/llvm_backend.cpp

@@ -10918,7 +10918,7 @@ lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue ri
 		}
 	}
 
-	if (is_type_array(a)) {
+	if (is_type_array(a) || is_type_enumerated_array(a)) {
 		Type *tl = base_type(a);
 		lbValue lhs = lb_address_from_load_or_generate_local(p, left);
 		lbValue rhs = lb_address_from_load_or_generate_local(p, right);
@@ -10935,7 +10935,11 @@ lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue ri
 		}
 
 		bool inline_array_arith = type_size_of(tl) <= build_context.max_align;
-		i32 count = cast(i32)tl->Array.count;
+		i32 count = 0;
+		switch (tl->kind) {
+		case Type_Array:           count = cast(i32)tl->Array.count;           break;
+		case Type_EnumeratedArray: count = cast(i32)tl->EnumeratedArray.count; break;
+		}
 
 		if (inline_array_arith) {
 			// inline