From 7089cbd8d6eee069b0eafdd74106a643f1159fef Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 2 Apr 2024 13:55:46 +0100 Subject: [PATCH] Fix type definition in `block` breaking parent scope Fixes #638 --- ford/sourceform.py | 2 +- test/test_sourceform.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ford/sourceform.py b/ford/sourceform.py index 9b7dacdf..162b0b6e 100644 --- a/ford/sourceform.py +++ b/ford/sourceform.py @@ -860,7 +860,7 @@ def __init__( blocklevel -= 1 elif endtype and endtype.lower() == "associate": associations.remove_last_batch() - else: + elif blocklevel == 0: self._cleanup() return diff --git a/test/test_sourceform.py b/test/test_sourceform.py index 857daec9..65b50501 100644 --- a/test/test_sourceform.py +++ b/test/test_sourceform.py @@ -2238,3 +2238,21 @@ def test_associate_array(parse_fortran_file): # Just check we can parse ok parse_fortran_file(data) + + +def test_blocks_with_type(parse_fortran_file): + data = """\ + module foo + contains + subroutine sub1() + block + type :: t1 + end type t1 + end block + end subroutine sub1 + end module foo + """ + + source = parse_fortran_file(data) + module = source.modules[0] + assert len(module.subroutines) == 1