diff --git a/vhdlpp/vtype_emit.cc b/vhdlpp/vtype_emit.cc index c33c68304..15bae48e3 100644 --- a/vhdlpp/vtype_emit.cc +++ b/vhdlpp/vtype_emit.cc @@ -98,9 +98,21 @@ int VTypeArray::emit_with_dims_(std::ostream&out, bool packed, perm_string name) list dims; const VTypeArray*cur = this; - while (const VTypeArray*sub = dynamic_cast (cur->element_type())) { - dims.push_back(cur); - cur = sub; + bool added_dim = true; + + while(added_dim) { + added_dim = false; + const VType*el_type = cur->element_type(); + + while(const VTypeDef*tdef = dynamic_cast(el_type)) { + el_type = tdef->peek_definition(); + } + + if(const VTypeArray*sub = dynamic_cast(el_type)) { + dims.push_back(cur); + cur = sub; + added_dim = true; + } } dims.push_back(cur);