Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/fparser/two/Fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -9329,7 +9329,9 @@ class Io_Implied_Do(Base): # R917

@staticmethod
def match(string):
if len(string) <= 9 or string[0] != "(" or string[-1] != ")":
# The shortest possible io-implied-do, e.g. "(i,i=1,2)", is 9
# characters long.
if len(string) < 9 or string[0] != "(" or string[-1] != ")":
return
line, repmap = string_replace_map(string[1:-1].strip())
i = line.rfind("=")
Expand Down
5 changes: 5 additions & 0 deletions src/fparser/two/tests/test_fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,11 @@ def test_io_implied_do(): # R917
assert isinstance(obj, tcls), repr(obj)
assert str(obj) == "(a, i = 1, 2)"

# Minimal-length (9-character) io-implied-do.
obj = tcls("(i,i=1,2)")
assert isinstance(obj, tcls), repr(obj)
assert str(obj) == "(i, i = 1, 2)"

obj = tcls("((i+j,j=3,4,1), i=1,2)")
assert isinstance(obj, tcls), repr(obj)
assert str(obj) == "((i + j, j = 3, 4, 1), i = 1, 2)"
Expand Down
Loading