Allow for cycles in record polymorphic parameters but not in actualized fields

This commit is contained in:
gingerBill
2019-10-26 11:50:42 +01:00
parent 1da0668653
commit 2c75fe2314
+10
View File
@@ -6127,6 +6127,14 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
defer (array_free(&operands)); defer (array_free(&operands));
bool named_fields = false; bool named_fields = false;
{
// NOTE(bill, 2019-10-26): Allow a cycle in the parameters but not in the fields themselves
auto prev_type_path = c->type_path;
c->type_path = new_checker_type_path();
defer ({
destroy_checker_type_path(c->type_path);
c->type_path = prev_type_path;
});
if (is_call_expr_field_value(ce)) { if (is_call_expr_field_value(ce)) {
named_fields = true; named_fields = true;
@@ -6170,6 +6178,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
check_unpack_arguments(c, lhs, lhs_count, &operands, ce->args, false, false); check_unpack_arguments(c, lhs, lhs_count, &operands, ce->args, false, false);
} }
}
CallArgumentError err = CallArgumentError_None; CallArgumentError err = CallArgumentError_None;
TypeTuple *tuple = get_record_polymorphic_params(original_type); TypeTuple *tuple = get_record_polymorphic_params(original_type);