From 0b92a8d53be07508d3479cd6bd09bd123f644ac3 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Sun, 15 Mar 2026 16:56:47 -0400 Subject: [PATCH 1/2] Fix TypeError when reporting ParseSyntaxError in parse_fortran_var_decl --- scripts/fortran_tools/parse_fortran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fortran_tools/parse_fortran.py b/scripts/fortran_tools/parse_fortran.py index 4b3605c1..bd876772 100644 --- a/scripts/fortran_tools/parse_fortran.py +++ b/scripts/fortran_tools/parse_fortran.py @@ -814,7 +814,7 @@ def parse_fortran_var_decl(line, source, run_env, imports=None): fortran_imports=imports) newvars.append(var) except ParseSyntaxError as perr: - errors.append(perr) + errors.append(str(perr)) # end try # end for # No else (not a variable declaration) From 22e37f43388271dd0db3aae91ac3d04236ee455f Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Sun, 15 Mar 2026 20:06:52 -0400 Subject: [PATCH 2/2] Add doctest testing for integer dimension indices --- scripts/fortran_tools/parse_fortran.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/fortran_tools/parse_fortran.py b/scripts/fortran_tools/parse_fortran.py index bd876772..ab072afd 100644 --- a/scripts/fortran_tools/parse_fortran.py +++ b/scripts/fortran_tools/parse_fortran.py @@ -701,6 +701,8 @@ def parse_fortran_var_decl(line, source, run_env, imports=None): ['8'] >>> parse_fortran_var_decl("character(len=*), intent(out) :: errmsg", ParseSource('foo.F90', 'module', ParseContext()), _DUMMY_RUN_ENV)[1][0] 'Syntax error: Invalid variable declaration, character(len=*), intent(out) :: errmsg, intent not allowed in module variable, in ' + >>> parse_fortran_var_decl("type(banana_t) :: bananas(0:N_FRUITS)", ParseSource('foo.F90', 'module', ParseContext()), _DUMMY_RUN_ENV)[1][0] + "bananas: '0:N_FRUITS' is an invalid dimension name; integer dimension indices not supported, in " ## NB: Expressions (including function calls) not currently supported here #>>> parse_fortran_var_decl("real(kind_phys), intent(out) :: foo(size(bar))", ParseSource('foo.F90', 'scheme', ParseContext()), _DUMMY_RUN_ENV)[0].get_prop_value('dimensions')