diff --git a/cxxheaderparser/parser.py b/cxxheaderparser/parser.py index f6ece2b..1ec3197 100644 --- a/cxxheaderparser/parser.py +++ b/cxxheaderparser/parser.py @@ -1749,6 +1749,7 @@ class CxxParser: return method.has_body or method.has_trailing_return else: + assert return_type is not None fn = Function( return_type, pqname, @@ -1778,8 +1779,12 @@ class CxxParser: if fn.template: raise CxxParseError("typedef function may not have a template") + return_type = fn.return_type + if return_type is None: + raise CxxParseError("typedef function must have return type") + fntype = FunctionType( - fn.return_type, + return_type, fn.parameters, fn.vararg, fn.has_trailing_return, diff --git a/cxxheaderparser/types.py b/cxxheaderparser/types.py index 8354427..7973b69 100644 --- a/cxxheaderparser/types.py +++ b/cxxheaderparser/types.py @@ -468,7 +468,9 @@ class Function: A function declaration, potentially with the function body """ - return_type: DecoratedType + #: Only constructors and destructors don't have a return type + return_type: typing.Optional[DecoratedType] + name: PQName parameters: typing.List[Parameter] @@ -510,9 +512,6 @@ class Method(Function): A method declaration, potentially with the method body """ - #: constructors and destructors don't have a return type - return_type: typing.Optional[DecoratedType] - access: str = "" const: bool = False