(Closes #505) by removing blank line comments being generated as Comment objects.#509
Conversation
|
I can't replicate the failing example, I have only python 3.12, but locally I get I will attempt to do the same test on rupert which has 3.14.5. |
|
It also worked for me on rupert with 3.14.5 so its a big mystery to me. Is there a known issue with this test at all? |
Feel free to use my branch in stfc/PSyclone#3440 You just need to update psyclone submodule to the commit you want to test and submit the integration tests. I was not planning to merge it until we had a new fparser release. |
|
@LonelyCat124 This example also fails for me (are you sure you don't have a preinstalled fparser in the environment that those examples would take), anyway the problem is that the linebreaks are gone: |
Ok apparently I ended up testing from the wrong branch. Anyway these extra line breaks are wrong, and are introduced by |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #509 +/- ##
=======================================
Coverage 92.23% 92.23%
=======================================
Files 88 88
Lines 13863 13861 -2
=======================================
- Hits 12786 12785 -1
+ Misses 1077 1076 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@sergisiso updated as requested. I also think the failing test was wrong rather than this PR, so I've fixed the expected output (it didn't match |
sergisiso
left a comment
There was a problem hiding this comment.
@LonelyCat124 I am ok with this implementation, but before approving let me ask if any of the comments below can improve things.
|
@sergisiso back to you - I think I don't understand some of the code enough to have a conclusion, but I think the linebreaks we were adding were a bug I introduced as opposed to something that fparser is meant to be able to output. I think we'd need some sort of special class to keep whitespace which I'm not sure how to do without replicating the issue fixed here. I did swap to using the deque, we can see if it makes any difference performance wise. |
sergisiso
left a comment
There was a problem hiding this comment.
@LonelyCat124 If in Rupert I do:
$ fparser2 --task=repr /archive/psyclone-tests/latest-run/slow_files/ukca_aero_ctl.F90
It still have the same problem (in this case only parses the top comments before the module, but not the actual module).
|
I'll take a look next then, thats odd but maybe some issue with comments more generally I've not considered. |
|
There's no syntax error in this file right? It looks like this file works with master so I've broken it somehow with this PR? I'll try to check why |
|
Ok I've worked out the problem and the fix is rough. The problem comes from which returns None to the original source of the issue here: in I'm going to try one other change, which is to see if we get an empty Comment at in BaseBlock.match if I just don't append a comment with an empty content to the content list, but I'm not sure if that will work or not. |
|
Thats still not the right place to filter out empty comments, I need to keep looking up the stack trace. This is turning into a lot of a mess... |
|
I've changed this to a much simpler fix, but we get the empty lines again for now that means that the issue in PSyclone with enabling comments changing the order of the fparser tree (empty lines introduce |
|
@sergisiso I've changed the implementation here, removing blank lines is not currently successful, it would need more rethinking, I think thats a problem for later. Feel free to test it on more repos as you feel would be worthwhile, both my syntax failure test and the file you said before now work though. |
|
@LonelyCat124 I confirm it now works with my examples as well (both with fparser2 and through psyclone). Unfortunately the deque didn't make any difference, but I still think it is a more logical choice for a FIFO, so let's keep it. |
sergisiso
left a comment
There was a problem hiding this comment.
@LonelyCat124 Everything looks good now, this is approved for merging.
|
A bit late now but did you try filtering them out in the FortranReader? |
I didn't, I can take a look perhaps, the current behaviour is we get the FortranStringReader (or whichever) readfortran.Comment objects, I'm not sure how that thing is built, maybe its possible to just not add them (since they're ignored anyway with comments not kept). |
|
Blank comments can be removed by adding: into |
@sergisiso This is ready for reivew if tests pass (though they may not, but they did locally so I will investigate if they don't).
I also think I'd like to test this doesn't break anything in PSyclone, but I need to think about how best to do that.