Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Closes #313) permit intrinsic shadowing #418

Merged
merged 23 commits into from
Jan 25, 2024

Conversation

arporter
Copy link
Member

No description provided.

@arporter arporter changed the title 313 permit intrinsic shadowing (Closes #313) permit intrinsic shadowing Jun 12, 2023
@arporter arporter marked this pull request as draft June 12, 2023 15:55
@arporter
Copy link
Member Author

Looking at the test failures and (lack of) code changes, it's clear that this branch needs refining so that it only permits a mismatch in arguments if an intrinsic has been (or could be?) overridden.

@arporter arporter self-assigned this Sep 14, 2023
@arporter
Copy link
Member Author

The trouble is that (in NEMOVAR), there isn't always an explicit import of the overridden intrinsic. Obviously, if we find a wildcard import and the tentative intrinsic match has an invalid number of arguments then we know it can't be an intrinsic and must be from elsewhere. However, if it happens to have the same number of arguments as the intrinsic then we will always match an Intrinsic, even if those arguments are of the wrong type. (In future we could check the type of the arguments.)

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5c3808d) 91.96% compared to head (f7ebb67) 91.99%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #418      +/-   ##
==========================================
+ Coverage   91.96%   91.99%   +0.02%     
==========================================
  Files          85       85              
  Lines       13644    13681      +37     
==========================================
+ Hits        12548    12586      +38     
+ Misses       1096     1095       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arporter arporter marked this pull request as ready for review September 14, 2023 13:44
@arporter
Copy link
Member Author

This has been needed for NEMOVAR for a while: currently we are over zealous in checking the number of arguments to intrinsics and fell foul of the fact that NEMOVAR overrides DOT_PRODUCT with something that can accept more args than the Fortran intrinsic can. This PR alters the parser's behaviour so that if the number of arguments don't match and there's somewhere that a symbol could be coming from then we don't match an intrinsic. I had to extend SymbolTable with a new wildcard_imports property to do this.
One for @sergisiso or @rupertford.

Copy link
Collaborator

@rupertford rupertford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job. I have mostly minor comments but you will see that I am a little concerned as to whether this solution works in situations other than module/subroutine.

src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/tests/fortran2003/test_intrinsics.py Outdated Show resolved Hide resolved
src/fparser/two/tests/test_symbol_table.py Show resolved Hide resolved
src/fparser/two/tests/test_symbol_table.py Show resolved Hide resolved
src/fparser/two/tests/test_symbol_table.py Show resolved Hide resolved
@rupertford rupertford added reviewed with actions PR has been reviewed and is back with developer and removed under review labels Sep 14, 2023
@arporter
Copy link
Member Author

I hadn't considered submodules so thanks for spotting that. Having done some reading I see that (as you'd expect) they have access to all the symbols made available by the 'parent' module. I'll have to allow for that.

@arporter arporter added in progress and removed reviewed with actions PR has been reviewed and is back with developer labels Sep 27, 2023
Copy link
Collaborator

@rupertford rupertford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just some minor requests.

src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/symbol_table.py Show resolved Hide resolved
src/fparser/two/tests/test_module_use.py Show resolved Hide resolved
@rupertford rupertford added reviewed with actions PR has been reviewed and is back with developer and removed under review labels Dec 5, 2023
@arporter arporter added ready for review and removed reviewed with actions PR has been reviewed and is back with developer labels Dec 6, 2023
@arporter
Copy link
Member Author

arporter commented Dec 6, 2023

Ready for another look now...

Copy link
Collaborator

@rupertford rupertford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. However, there appears to be a line that is not covered by the tests. Could you please check and fix if required.

@rupertford rupertford added reviewed with actions PR has been reviewed and is back with developer and removed under review labels Dec 20, 2023
@arporter arporter added in progress and removed reviewed with actions PR has been reviewed and is back with developer labels Jan 4, 2024
@arporter
Copy link
Member Author

arporter commented Jan 4, 2024

Thanks for spotting that missed line - I'd been fooled by Codecov reporting success. Happily that line was associated with #170 (which is now fixed) and so I've been able to simplify it.
Ready for another look.

Copy link
Collaborator

@sergisiso sergisiso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with @arporter I took over this review in order to add this functionality to the next release. I see that @rupertford was already happy with how his previous comments were addressed and just one line on the codecov was missing. So I just gave it a quick read and checked that the codecov is now complete. This PR is ready to merge.

@sergisiso sergisiso added ready for merge PR is waiting on final CI checks before being merged. and removed under review labels Jan 25, 2024
@sergisiso sergisiso merged commit 0410062 into master Jan 25, 2024
6 checks passed
@sergisiso sergisiso deleted the 313_permit_intrinsic_shadowing branch January 25, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for merge PR is waiting on final CI checks before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants