Fortran-FOSS-Programmers / Fortran-FOSS-Programmers/ford

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

Open
#739 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
458
Forks
138
PR merge metrics
No merged PRs in 30d

Description

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:

```markdown
> cat ford.md
project: Formal
src_dir: .
preprocess: false
```
```fortran
> 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
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
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Run `ford ford.md` against the reproducing `tensors_1D_m.f90` input first. Then inspect the binding rendering path in `ford/templates/macros.html`, especially `binding_summary` and `proc_line`, alongside the parser's handling of the private parent binding. Done means the example renders without the unknown-entity error and documents the generic binding correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran, python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.