Skip to content

Parsing error when a generic binding references a parent's private binding #739

Description

@rouson

The transcript below reproduces an error that occurs when ford attempts to parse a derived type that defines a generic binding corresponding to a parent type's private binding:

> cat ford.md 
project: Formal
src_dir: .
preprocess: false
> cat tensors_1D_m.f90 
module tensors_1D_m
  implicit none

  type tensor_1D_t
  contains
    procedure, private :: gradient_1D_weights
  end type

  type, extends(tensor_1D_t) :: vector_1D_t
  contains
    generic :: weights => gradient_1D_weights
  end type

  interface
    module function gradient_1D_weights(self) result(weights)
      implicit none
      class(tensor_1D_t), intent(in) :: self
      double precision, allocatable :: weights(:)
    end function
  end interface

end module
> ford ford.md
  Parsing files         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 1/1 0:00:00 0:00:00 tensors_1D_m.f90
  Correlating information from different parts of your project...
  ...done in 0.000s
  Processing comments   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 11/11 0:00:00 0:00:00 gradient_1D_weights
  Creating HTML documentation... done in 0.000s
Error rendering page '/Users/rouson/Repositories/formal/doc/type/vector_1d_t.html'
⠙ Creating search index ━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━  40% 2/5 0:00:01 0:00:00 type/vector_1d_t.html
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/output.py", line 359, in html
    return self.render(self.data, self.proj, self.obj)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/output.py", line 489, in render
    return self.template.render(
           ~~~~~~~~~~~~~~~~~~~~^
        data, project=project, **{self.payload_key: object}
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/environment.py", line 1295, in render
    self.environment.handle_exception()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/environment.py", line 942, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/type_page.html", line 3, in top-level template code
    {% extends "base.html" %}
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/base.html", line 144, in top-level template code
    {% block body %}
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/type_page.html", line 96, in block 'body'
    {{ macros.bound_info(bp) }}
    ^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/runtime.py", line 784, in _invoke
    rv = self._func(*arguments)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/macros.html", line 389, in template
    {{ binding_summary(bind) }}
    ^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/runtime.py", line 784, in _invoke
    rv = self._func(*arguments)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/macros.html", line 302, in template
    {{ proc_line(proc, proto=proto) }}
    ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/runtime.py", line 784, in _invoke
    rv = self._func(*arguments)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/macros.html", line 473, in template
    {{ deprecated(proc) }}
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/jinja2/runtime.py", line 784, in _invoke
    rv = self._func(*arguments)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/templates/macros.html", line 173, in template
    {%- if entity | meta('deprecated') -%}
    ^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: Unknown entity 'gradient_1D_weights': This likely means an error in parsing, please check that this file compiles with a Fortran compiler

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/ford", line 6, in <module>
    sys.exit(run())
             ~~~^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/__init__.py", line 509, in run
    main(proj_data, proj_docs)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/__init__.py", line 493, in main
    docs = ford.output.Documentation(proj_data, proj_docs, project, page_tree)
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/output.py", line 256, in __init__
    self.tipue.create_node(page.html, page.loc, page.meta)
                           ^^^^^^^^^
  File "/opt/homebrew/Cellar/ford/7.0.13_2/libexec/lib/python3.14/site-packages/ford/output.py", line 361, in html
    raise RuntimeError(
    ...<3 lines>...
    )
RuntimeError: Error rendering 'vector_1d_t.html':
  File "tensors_1D_m.f90": type "vector_1D_t"
    Unknown entity 'gradient_1D_weights': This likely means an error in parsing, please check that this file compiles with a Fortran compiler

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions