fix compile error regression with struct containing itself

This commit is contained in:
Andrew Kelley 2020-01-28 11:52:48 -05:00
parent 287d3c37e1
commit 5c55a9b4e8
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -5641,6 +5641,8 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
return OnePossibleValueYes;
return type_has_one_possible_value(g, type_entry->data.array.child_type);
case ZigTypeIdStruct:
// If the recursive function call asks, then we are not one possible value.
type_entry->one_possible_value = OnePossibleValueNo;
for (size_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
TypeStructField *field = type_entry->data.structure.fields[i];
OnePossibleValue opv = (field->type_entry != nullptr) ?
@ -5648,6 +5650,7 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
type_val_resolve_has_one_possible_value(g, field->type_val);
switch (opv) {
case OnePossibleValueInvalid:
type_entry->one_possible_value = OnePossibleValueInvalid;
return OnePossibleValueInvalid;
case OnePossibleValueNo:
return OnePossibleValueNo;
@ -5655,6 +5658,7 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
continue;
}
}
type_entry->one_possible_value = OnePossibleValueYes;
return OnePossibleValueYes;
case ZigTypeIdErrorSet:
case ZigTypeIdEnum: