mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix enumerated array contiguous error
This commit is contained in:
+3
-6
@@ -8125,12 +8125,9 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) {
|
||||||
if (t->kind == Type_EnumeratedArray) {
|
if (0 < max && max < t->EnumeratedArray.count) {
|
||||||
if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) {
|
error(node, "Expected %lld values for this enumerated array literal, got %lld", cast(long long)t->EnumeratedArray.count, cast(long long)max);
|
||||||
if (0 < max && max < t->EnumeratedArray.count) {
|
|
||||||
error(node, "Expected %lld values for this enumerated array literal, got %lld", cast(long long)t->EnumeratedArray.count, cast(long long)max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-12
@@ -3252,18 +3252,16 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->EnumeratedArray.count != bt->Enum.fields.count) {
|
if (!is_partial && t->EnumeratedArray.count > bt->Enum.fields.count) {
|
||||||
if (!is_partial) {
|
error(e, "Non-contiguous enumeration used as an index in an enumerated array");
|
||||||
error(e, "Non-contiguous enumeration used as an index in an enumerated array");
|
long long ea_count = cast(long long)t->EnumeratedArray.count;
|
||||||
long long ea_count = cast(long long)t->EnumeratedArray.count;
|
long long enum_count = cast(long long)t->Enum.fields.count;
|
||||||
long long enum_count = cast(long long)t->Enum.fields.count;
|
error_line("\tenumerated array length: %lld\n", ea_count);
|
||||||
error_line("\tenumerated array length: %lld\n", ea_count);
|
error_line("\tenum field count: %lld\n", enum_count);
|
||||||
error_line("\tenum field count: %lld\n", enum_count);
|
error_line("\tSuggestion: prepend #partial to the enumerated array to allow for non-named elements\n");
|
||||||
error_line("\tSuggestion: prepend #partial to the enumerated array to allow for non-named elements\n");
|
if (2*enum_count < ea_count) {
|
||||||
if (2*enum_count < ea_count) {
|
error_line("\tWarning: the number of named elements is much smaller than the length of the array, are you sure this is what you want?\n");
|
||||||
error_line("\tWarning: the number of named elements is much smaller than the length of the array, are you sure this is what you want?\n");
|
error_line("\t this warning will be removed if #partial is applied\n");
|
||||||
error_line("\t this warning will be removed if #partial is applied\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user