Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"assert parentSymbol" in cpp domain when input is misaligned #5191

Closed
randombit opened this issue Jul 17, 2018 · 1 comment · Fixed by #5269
Closed

"assert parentSymbol" in cpp domain when input is misaligned #5191

randombit opened this issue Jul 17, 2018 · 1 comment · Fixed by #5269
Assignees

Comments

@randombit
Copy link

The following input causes an assertion failure:

My Thing
===========

.. cpp:class:: Class

      .. cpp:function:: Class(int f)

         Does something with ints

     .. cpp:function:: Class(double f)

         Does something with doubles

      .. cpp:function:: Class(string f)

         Does something with strings

Note that the second declaration is not indented correctly (one space is missing).

This causes the following error:

Target:  string.. [100%] floof                                                                                                                                                                 
ParentKey:  [(<ASTNestedNameElement Class>, None), (<ASTNestedNameElement Class>, None), (<ASTNestedNameElement Class>, None)]

Exception occurred:
  File "/usr/lib/python3.6/site-packages/sphinx/domains/cpp.py", line 6133, in _resolve_xref_inner
    assert parentSymbol  # should be there
AssertionError
The full traceback has been saved in /home/jack/var/tmp/sphinx-err-851mc0mm.log, if you want to report the issue to the developers.

Traceback log is

# Sphinx version: 1.7.5
# Python version: 3.6.6 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.10
# Last messages:
#   done
#   
#   preparing documents...
#   
#   done
#   
#   writing output... [ 50%] contents
#   
#   writing output... [100%] floof
#   
# Loaded extensions:
#   alabaster (0.7.11) from /usr/lib/python3.6/site-packages/alabaster/__init__.py
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/sphinx/cmdline.py", line 304, in main
    app.build(args.force_all, filenames)
  File "/usr/lib/python3.6/site-packages/sphinx/application.py", line 331, in build
    self.builder.build_update()
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 342, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 403, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 440, in write
    self._write_serial(sorted(docnames))
  File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 447, in _write_serial
    doctree = self.env.get_and_resolve_doctree(docname, self)
  File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 813, in get_and_resolve_doctree
    self.apply_post_transforms(doctree, docname)
  File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 860, in apply_post_transforms
    transformer.apply_transforms()
  File "/usr/lib/python3.6/site-packages/sphinx/transforms/__init__.py", line 96, in apply_transforms
    Transformer.apply_transforms(self)
  File "/usr/lib/python3.6/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/usr/lib/python3.6/site-packages/sphinx/transforms/post_transforms/__init__.py", line 90, in apply
    typ, target, node, contnode)
  File "/usr/lib/python3.6/site-packages/sphinx/domains/cpp.py", line 6205, in resolve_xref
    target, node, contnode)[0]
  File "/usr/lib/python3.6/site-packages/sphinx/domains/cpp.py", line 6133, in _resolve_xref_inner
    assert parentSymbol  # should be there
AssertionError

Of course indenting correctly fixes the issue, but this took some time to figure out.

There are a couple of other issues about this assertion (#2413, #2536) but they seem to be caused by an unrelated (and already fixed) issue with handling duplicate declarations.

  • OS: Arch Linux
  • Python version: 3.6.6
  • Sphinx version: 1.7.5
@jakobandersen
Copy link
Contributor

Thanks for reporting! It should be fixed in the upcoming version 1.8. A warning will be issue for the last declaration (Class(string f)), that it is a nested declaration of another function, and the declaration (along with any content) will be completely ignored.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants