Skip to content

Commit 758abb9

Browse files
committed
C++, fix bug in type alias parsing.
Fixes #2061
1 parent df3d647 commit 758abb9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sphinx/domains/cpp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ def __init__(self, name, type):
18291829
self.type = type
18301830

18311831
def get_id_v1(self, objectType=None, symbol=None):
1832-
return None
1832+
raise NoOldIdError()
18331833

18341834
def get_id_v2(self, objectType=None, symbol=None):
18351835
return symbol.get_full_nested_name().get_id_v2()
@@ -3198,11 +3198,13 @@ def parse_declaration(self, objectType):
31983198

31993199
if objectType == 'type':
32003200
error = None
3201+
pos = self.pos
32013202
try:
32023203
if not templatePrefix:
32033204
declaration = self._parse_type(named=True, outer='type')
32043205
except DefinitionError as e:
32053206
error = e.description
3207+
self.pos = pos
32063208
try:
32073209
if not declaration:
32083210
declaration = self._parse_type_using()

tests/test_domain_cpp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ def test_type_definitions():
246246
check('enumerator', 'A = std::numeric_limits<unsigned long>::max()',
247247
None, "1A")
248248

249+
check('type', 'A = B', None, '1A')
250+
249251

250252
def test_fundamental_types():
251253
# see http://en.cppreference.com/w/cpp/language/types

0 commit comments

Comments
 (0)