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

Ford crashes if a generic binding references a procedure binding that lacks a double colon #505

Closed
rouson opened this issue Apr 22, 2023 · 1 comment · Fixed by #512
Closed
Labels

Comments

@rouson
Copy link
Contributor

rouson commented Apr 22, 2023

As the transcript below demonstrates ford version 6.2.4 crashes when a type-bound procedure binding doesn't include a double colon (::) and the procedure is a specific binding referenced by a generic binding on the same type. The crash disappears if either a double-colon is added to the procedure binding (procedure :: total) or if the generic binding is removed.

% tree 
.
├── ford.md
└── src
    └── subdomain_m.f90

1 directory, 2 files

% cat ford.md 
---
project: Reproducer

% cat src/subdomain_m.f90 
module subdomain_m
  type subdomain_t 
  contains
    procedure total
    generic :: operator(+) => total
  end type
  interface
    module function total(lhs, rhs)
      class(subdomain_t), intent(in) :: lhs, rhs
      type(subdomain_t) total
    end function
  end interface
end module

% ford --version
ford version 6.2.4

% ford ford.md 
Reading file src/subdomain_m.f90

Processing documentation comments...
Correlating information from different parts of your project...

Creating HTML documentation...
Creating search index:   0%|                                                                                  | 0/4 [00:00<?, ?/s]Error rendering page '/Users/rouson/Repositories/ford-reproducer/doc/type/subdomain_t.html'
Creating search index:   0%|                                                                                  | 0/4 [00:00<?, ?/s]
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/output.py", line 290, in html
    return self.render(self.data, self.proj, self.obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/output.py", line 424, in render
    return template.render(data, project=project, **{self.payload_key: object})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/type_page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/base.html", line 151, in top-level template code
    {% block body %}
^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/type_page.html", line 92, in block 'body'
    {{ macros.bound_info(bp) }}
^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/macros.html", line 351, in template
    {{ binding_summary(bind) }}
^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/macros.html", line 284, in template
    {{ proc_line(proc, proto=proto) }}
^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/macros.html", line 428, in template
    {{ deprecated(proc) }}
  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/templates/macros.html", line 156, in template
    {%- if entity.meta['deprecated'] -%}
  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/jinja2/environment.py", line 466, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'meta'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/ford", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/__init__.py", line 648, in run
    main(proj_data, proj_docs, md)
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/__init__.py", line 632, in main
    docs = ford.output.Documentation(proj_data, proj_docs_, project, page_tree)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/output.py", line 189, in __init__
    self.tipue.create_node(p.html, p.loc, p.meta)
                           ^^^^^^
  File "/opt/homebrew/Cellar/ford/HEAD-69c2084/libexec/lib/python3.11/site-packages/ford/output.py", line 292, in html
    raise RuntimeError(
RuntimeError: Error rendering 'subdomain_t.html' for 'subdomain_t' : 'str object' has no attribute 'meta'
@ZedThree ZedThree added the bug label Apr 24, 2023
@ZedThree
Copy link
Member

Oof, not good! Thanks for the very clear reproducer @rouson, I will try and get this fixed as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants