mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-20 12:44:59 -07:00
Fix polymorphic record "too few" lacking error message
This commit is contained in:
+10
-2
@@ -5286,8 +5286,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
||||
TypeTuple *tuple = get_record_polymorphic_params(original_type);
|
||||
isize param_count = tuple->variables.count;
|
||||
isize minimum_param_count = param_count;
|
||||
for (minimum_param_count = tuple->variables.count-1; minimum_param_count >= 0; minimum_param_count--) {
|
||||
Entity *e = tuple->variables[minimum_param_count];
|
||||
for (; minimum_param_count > 0; minimum_param_count--) {
|
||||
Entity *e = tuple->variables[minimum_param_count-1];
|
||||
if (e->kind != Entity_Constant) {
|
||||
break;
|
||||
}
|
||||
@@ -5296,6 +5296,7 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Array<Operand> ordered_operands = operands;
|
||||
if (!named_fields) {
|
||||
ordered_operands = array_make<Operand>(permanent_allocator(), param_count);
|
||||
@@ -5367,6 +5368,13 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
||||
return err;
|
||||
}
|
||||
|
||||
while (ordered_operands.count >= 0) {
|
||||
if (ordered_operands[ordered_operands.count-1].expr != nullptr) {
|
||||
break;
|
||||
}
|
||||
array_pop(&ordered_operands);
|
||||
}
|
||||
|
||||
if (minimum_param_count != param_count) {
|
||||
if (param_count < ordered_operands.count) {
|
||||
error(call, "Too many polymorphic type arguments, expected a maximum of %td, got %td", param_count, ordered_operands.count);
|
||||
|
||||
@@ -250,9 +250,14 @@ Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type,
|
||||
|
||||
bool skip = false;
|
||||
|
||||
GB_ASSERT(ordered_operands.count >= param_count);
|
||||
|
||||
for (isize j = 0; j < param_count; j++) {
|
||||
Entity *p = tuple->variables[j];
|
||||
Operand o = ordered_operands[j];
|
||||
if (o.expr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
Entity *oe = entity_of_node(o.expr);
|
||||
if (p == oe) {
|
||||
// NOTE(bill): This is the same type, make sure that it will be be same thing and use that
|
||||
|
||||
+1
-1
@@ -937,7 +937,7 @@ Type *type_of_expr(Ast *expr) {
|
||||
}
|
||||
|
||||
Entity *implicit_entity_of_node(Ast *clause) {
|
||||
if (clause->kind == Ast_CaseClause) {
|
||||
if (clause != nullptr && clause->kind == Ast_CaseClause) {
|
||||
return clause->CaseClause.implicit_entity;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user