Skip to content

Commit 12cc097

Browse files
committed
fix: handle namedtypes correctly
1 parent 9290fef commit 12cc097

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rosidl_parser/rosidl_parser/idl_to_message_spec.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def resolve_typename(member_type: Type[idl_def.AbstractType]) -> str:
5454
def build_type_string(member_type: Type[idl_def.AbstractType], constants: List[idl_def.Constant]) -> str:
5555
type_string = resolve_typename(member_type)
5656

57+
if isinstance(member_type, idl_def.AbstractNestedType):
58+
if isinstance(member_type.value_type, idl_def.NamespacedType):
59+
type_string = f"{member_type.value_type.namespaces[0]}/{type_string}"
60+
5761
if type_string in IDL_TYPE_TO_MSG:
5862
type_string = IDL_TYPE_TO_MSG[type_string]
5963
elif type_string in UNSUPPORTED_ROSIDL_TYPES:
@@ -108,7 +112,7 @@ def process_members(members: List[idl_def.Member], constants: List[idl_def.Const
108112
type_pkg_name = None
109113
type_string = build_type_string(m.type, constants)
110114

111-
if isinstance(m.type, idl_def.NamespacedType):
115+
if isinstance(m.type, idl_def.NamedType):
112116
type_pkg_name = m.type.namespaces[0]
113117

114118
field_type = rosidl_parser.Type(type_string, type_pkg_name)

0 commit comments

Comments
 (0)