Fix cyclic polymorphic struct bug #111

This commit is contained in:
Ginger Bill
2017-10-01 14:10:31 +01:00
parent 5259de5872
commit e7e51f53ce
2 changed files with 19 additions and 11 deletions
+9 -3
View File
@@ -348,9 +348,15 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
switch (base_type(t)->kind) {
case Type_Struct:
case Type_Union: {
String *name = map_get(&m->entity_names, hash_pointer(t->Named.type_name));
GB_ASSERT_MSG(name != nullptr, "%.*s %p", LIT(t->Named.name), t->Named.type_name);
ir_print_encoded_local(f, *name);
GB_ASSERT(t->Named.type_name != nullptr);
String *found = map_get(&m->entity_names, hash_entity(t->Named.type_name));
if (found) {
ir_print_encoded_local(f, *found);
} else {
// TODO(bill): Is this correct behaviour?!
ir_print_type(f, m, base_type(t));
// GB_ASSERT_MSG(found != nullptr, "%.*s %p", LIT(t->Named.name), t->Named.type_name);
}
} break;
default:
ir_print_type(f, m, base_type(t));