mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Fix "Polymorphic parameter declared in return type doesn't compile #464" by giving a conversion error (code wasn't handling polymorphic result types as intended)
This commit is contained in:
+6
-2
@@ -5731,9 +5731,13 @@ Entity **populate_proc_parameter_list(CheckerContext *c, Type *proc_type, isize
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// NOTE(bill): Create 'lhs' list in order to ignore parameters which are polymorphic
|
// NOTE(bill): Create 'lhs' list in order to ignore parameters which are polymorphic
|
||||||
lhs_count = pt->params->Tuple.variables.count;
|
if (pt->params == nullptr) {
|
||||||
|
lhs_count = 0;
|
||||||
|
} else {
|
||||||
|
lhs_count = pt->params->Tuple.variables.count;
|
||||||
|
}
|
||||||
lhs = gb_alloc_array(heap_allocator(), Entity *, lhs_count);
|
lhs = gb_alloc_array(heap_allocator(), Entity *, lhs_count);
|
||||||
for_array(i, pt->params->Tuple.variables) {
|
for (isize i = 0; i < lhs_count; i++) {
|
||||||
Entity *e = pt->params->Tuple.variables[i];
|
Entity *e = pt->params->Tuple.variables[i];
|
||||||
if (!is_type_polymorphic(e->type)) {
|
if (!is_type_polymorphic(e->type)) {
|
||||||
lhs[i] = e;
|
lhs[i] = e;
|
||||||
|
|||||||
@@ -2507,6 +2507,16 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (isize i = 0; i < result_count; i++) {
|
||||||
|
Entity *e = results->Tuple.variables[i];
|
||||||
|
if (e->kind != Entity_Variable) {
|
||||||
|
is_polymorphic = true;
|
||||||
|
break;
|
||||||
|
} else if (is_type_polymorphic(e->type)) {
|
||||||
|
is_polymorphic = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
type->Proc.is_polymorphic = is_polymorphic;
|
type->Proc.is_polymorphic = is_polymorphic;
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
Reference in New Issue
Block a user