mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00: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);
|
TypeTuple *tuple = get_record_polymorphic_params(original_type);
|
||||||
isize param_count = tuple->variables.count;
|
isize param_count = tuple->variables.count;
|
||||||
isize minimum_param_count = param_count;
|
isize minimum_param_count = param_count;
|
||||||
for (minimum_param_count = tuple->variables.count-1; minimum_param_count >= 0; minimum_param_count--) {
|
for (; minimum_param_count > 0; minimum_param_count--) {
|
||||||
Entity *e = tuple->variables[minimum_param_count];
|
Entity *e = tuple->variables[minimum_param_count-1];
|
||||||
if (e->kind != Entity_Constant) {
|
if (e->kind != Entity_Constant) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5296,6 +5296,7 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Array<Operand> ordered_operands = operands;
|
Array<Operand> ordered_operands = operands;
|
||||||
if (!named_fields) {
|
if (!named_fields) {
|
||||||
ordered_operands = array_make<Operand>(permanent_allocator(), param_count);
|
ordered_operands = array_make<Operand>(permanent_allocator(), param_count);
|
||||||
@@ -5367,6 +5368,13 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
|
|||||||
return err;
|
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 (minimum_param_count != param_count) {
|
||||||
if (param_count < ordered_operands.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);
|
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;
|
bool skip = false;
|
||||||
|
|
||||||
|
GB_ASSERT(ordered_operands.count >= param_count);
|
||||||
|
|
||||||
for (isize j = 0; j < param_count; j++) {
|
for (isize j = 0; j < param_count; j++) {
|
||||||
Entity *p = tuple->variables[j];
|
Entity *p = tuple->variables[j];
|
||||||
Operand o = ordered_operands[j];
|
Operand o = ordered_operands[j];
|
||||||
|
if (o.expr == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
Entity *oe = entity_of_node(o.expr);
|
Entity *oe = entity_of_node(o.expr);
|
||||||
if (p == oe) {
|
if (p == oe) {
|
||||||
// NOTE(bill): This is the same type, make sure that it will be be same thing and use that
|
// 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) {
|
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 clause->CaseClause.implicit_entity;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user