Skip to content

ford crashes on module procedure with interface body in same scope #446

Closed
@rouson

Description

@rouson
 % tree .
.
├── ford.md
└── src
    └── foo_m.f90

1 directory, 2 files
% cat ford.md 
---
project: Foo
summary: yada yada yada
src_dir: src/

On November 21, 2022, I edited the source code below to add an underscore to the interface name to ensure that the code is standard-conforming and to indicate that matching the interface name and procedure name were a mistake in my original post -- probably something that happened while trying to develop a short reproducer for the ford bug:

% cat src/foo_m.f90 
module foo_m
  implicit none

  interface foo_

    module function foo() result(bar)
      implicit none
      logical bar
    end function

  end interface

contains

  module procedure foo
    bar = .true.
  end procedure

end module
% ford ford.md
Reading file src/foo_m.f90
ERROR in file 'foo_m.f90': Unexpected MODULE PROCEDURE in module 'foo_m':
	module procedure foo
ERROR in file 'foo_m.f90': END statement outside of any nesting:
	end module
Traceback (most recent call last):
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/fortran_project.py", line 108, in __init__
    ford.sourceform.FortranSourceFile(
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/sourceform.py", line 1389, in __init__
    FortranContainer.__init__(self, source, "")
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/sourceform.py", line 789, in __init__
    self._cleanup()
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/sourceform.py", line 1033, in _cleanup
    raise NotImplementedError()
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/ford", line 8, in <module>
    sys.exit(run())
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/__init__.py", line 645, in run
    main(proj_data, proj_docs, md)
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/__init__.py", line 568, in main
    project = ford.fortran_project.Project(proj_data)
  File "/usr/local/Cellar/ford/6.1.15/libexec/lib/python3.10/site-packages/ford/fortran_project.py", line 121, in __init__
    print(f"Warning: Error parsing {relative_path}.\n\t{e.args[0]}")
IndexError: tuple index out of range
% ford --version
ford version 6.1.15

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