C, C++, fix KeyError due to alias directive

This commit is contained in:
Jakob Lykke Andersen 2021-04-18 16:39:58 +02:00
parent 8ec937d4c9
commit 025ec263f9
3 changed files with 7 additions and 2 deletions

View File

@ -24,6 +24,9 @@ Features added
Bugs fixed
----------
* C, C++, fix ``KeyError`` when an ``alias`` directive is the first C/C++
directive in a file with another C/C++ directive later.
Testing
--------

View File

@ -3454,7 +3454,8 @@ class AliasNode(nodes.Element):
if 'c:parent_symbol' not in env.temp_data:
root = env.domaindata['c']['root_symbol']
env.temp_data['c:parent_symbol'] = root
self.parentKey = env.temp_data['c:parent_symbol'].get_lookup_key()
env.ref_context['c:parent_key'] = root.get_lookup_key()
self.parentKey = env.ref_context['c:parent_key']
else:
assert parentKey is not None
self.parentKey = parentKey

View File

@ -7177,7 +7177,8 @@ class AliasNode(nodes.Element):
if 'cpp:parent_symbol' not in env.temp_data:
root = env.domaindata['cpp']['root_symbol']
env.temp_data['cpp:parent_symbol'] = root
self.parentKey = env.temp_data['cpp:parent_symbol'].get_lookup_key()
env.ref_context['cpp:parent_key'] = root.get_lookup_key()
self.parentKey = env.ref_context['cpp:parent_key']
else:
assert parentKey is not None
self.parentKey = parentKey