aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2023-10-01 13:09:08 +0200
committerjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2023-10-01 13:09:08 +0200
commit1a57ad233d06e52e486f717ddea1ce15934657eb (patch)
treed45923b45bf5b639d34fa946df55ac6dda7d46fa /src/types.cpp
parentc2684634132c0af6f2bd042280fcf667576fceb5 (diff)
Fix field count in enumerated array type info
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/types.cpp b/src/types.cpp
index f3062365f..574e628c5 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -983,7 +983,7 @@ gb_internal Type *alloc_type_matrix(Type *elem, i64 row_count, i64 column_count,
}
-gb_internal Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValue const *min_value, ExactValue const *max_value, TokenKind op) {
+gb_internal Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValue const *min_value, ExactValue const *max_value, isize count, TokenKind op) {
Type *t = alloc_type(Type_EnumeratedArray);
t->EnumeratedArray.elem = elem;
t->EnumeratedArray.index = index;
@@ -993,7 +993,11 @@ gb_internal Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValu
gb_memmove(t->EnumeratedArray.max_value, max_value, gb_size_of(ExactValue));
t->EnumeratedArray.op = op;
- t->EnumeratedArray.count = 1 + exact_value_to_i64(exact_value_sub(*max_value, *min_value));
+ if (count == 0) {
+ t->EnumeratedArray.count = 0;
+ } else {
+ t->EnumeratedArray.count = 1 + exact_value_to_i64(exact_value_sub(*max_value, *min_value));
+ }
return t;
}