Fix Io_Implied_Do rejecting a minimal-length io-implied-do (closes #524) - #525
Conversation
The length guard in Io_Implied_Do.match used '<= 9' but the shortest legal io-implied-do, e.g. '(i,i=1,n)', is exactly 9 characters, so statements such as 'WRITE (IOUT,10) N,(I,I=1,J)' failed to parse. Found while parsing MODFLOW-2005 (gwf2swr7.f). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3bf6c1e to
7989061
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes an off-by-one length check in Io_Implied_Do.match that incorrectly rejected the shortest valid io-implied-do form (9 characters, e.g. (i,i=1,n)), causing valid WRITE statements to fail to parse (as reported in issue #524).
Changes:
- Adjust
Io_Implied_Do.matchguard fromlen(string) <= 9tolen(string) < 9to allow minimal-length io-implied-do constructs. - Add a regression test covering the 9-character minimal-length case in
test_io_implied_do. - Add a corresponding entry to
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/fparser/two/Fortran2003.py | Fixes the io-implied-do length guard off-by-one so minimal valid constructs are accepted. |
| src/fparser/two/tests/test_fortran2003.py | Adds a regression test for a minimal-length io-implied-do string. |
| CHANGELOG.md | Records the bugfix and references the associated issue/PR. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #525 +/- ##
=======================================
Coverage 92.25% 92.25%
=======================================
Files 89 89
Lines 13891 13891
=======================================
Hits 12815 12815
Misses 1076 1076 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
arporter
left a comment
There was a problem hiding this comment.
All looks good, thanks very much @DisciplinedSoftware.
Please note that it is the code reviewer who updates the changelog as that's the last thing that must be done before the final merge. We get conflicts otherwise.
Closes #524.
The length guard in
Io_Implied_Do.matchused<= 9, but the shortest legal io-implied-do, e.g.(i,i=1,n), is exactly 9 characters, so statements such asWRITE (IOUT,10) N,(I,I=1,J)failed to parse (found while parsing MODFLOW-2005,gwf2swr7.f:4074). The guard is changed to< 9and a minimal-length case is added totest_io_implied_do.pytest src/fparserpasses (2950 passed, 24 xfailed, 1 pre-existing xpassed)blackclean🤖 Generated with Claude Code