Skip to content

Conversation

@sergisiso
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (bc9b4db) to head (2a2978e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3267   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files         377      377           
  Lines       53667    53707   +40     
=======================================
+ Hits        53645    53685   +40     
  Misses         22       22           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sergisiso
Copy link
Collaborator Author

@arporter @LonelyCat124 This is ready for review. It fixes a couple of issue we have parsing derived types.

@sergisiso sergisiso self-assigned this Jan 8, 2026
@sergisiso sergisiso changed the title (closes #3265 and #1418) Improve handling of derived type with unsupported components (closes #3265 and #1418) Improve parsing of derived type with unsupported components Jan 8, 2026
@sergisiso sergisiso changed the title (closes #3265 and #1418) Improve parsing of derived type with unsupported components (closes #3265 and #1418) Improve parsing derived type with unsupported components Jan 8, 2026
@sergisiso sergisiso changed the title (closes #3265 and #1418) Improve parsing derived type with unsupported components (closes #3265 and #1418) Improve parsing Fortran Derived Types with unsupported components Jan 8, 2026
Copy link
Member

@arporter arporter 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 Sergi. Just need a few comments and clarification of a couple of things. Plus testing for CONTAINS.

'''
if not isinstance(symbol, Symbol):
raise TypeError(f"Expected a Symbol but got '{type(symbol).__name__}'")
if not isinstance(symbol, (Symbol, StructureType.ComponentType)):
Copy link
Member

Choose a reason for hiding this comment

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

Pls update the :raises: part of the docstring too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

this contains the single entry "*".
:param preceding_comments: list of comments preceding the declaration.
:raise SymbolError: a symbol with the same name already in the given
Copy link
Member

Choose a reason for hiding this comment

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

"... is already"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

= self._comments_list_to_string(
preceding_comments)
preceding_comments = []
self._last_psyir_parsed_and_span\
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me/add comment what this is for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


preceding_comments = []
for child in decl.children:
for child in decl.children[1:]:
Copy link
Member

Choose a reason for hiding this comment

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

Comment on the use of 1: please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

raise NotImplementedError(
"Derived-type definition contains unsupported attributes.")

# We don't yet support derived-type definitions with a CONTAINS
Copy link
Member

Choose a reason for hiding this comment

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

Note to myself to remember to check that the appropriate test is updated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It already exists in src/psyclone/tests/psyir/frontend/fparser2_derived_type_test.py::test_derived_type_contains

:param symbol_table: the symbol table in which to add new symbols.
:param visibility_map: mapping of symbol names to explicit
visibilities.
:type visibility_map: dict with str keys and values of type
Copy link
Member

Choose a reason for hiding this comment

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

Pls mv this to be a type-hint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

:param scope: PSyIR node in which to insert the symbols found.
:type scope: :py:class:`psyclone.psyir.nodes.ScopingNode`
:param scope: the PSyIR location of the declaration.
:param symbol_table: the symbol table in which to add new symbols.
Copy link
Member

Choose a reason for hiding this comment

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

I was going to ask before but presumably you've added this because sometimes we don't want to use the scope.symbol_table?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, sometimes we populate a new symbol_table, but we still provide the original scope so that variables on the dimensions/initialisation expressions can be found.

I have to admit this is a bit concerning to me but the _process_decl already had this signature, I am just passing it down, so it behaves the same as the _process_decl implies it does.

self._process_decl_or_create_unsupported(
parent, local_table, component,
preceding_comments=preceding_comments)
preceding_comments = []
Copy link
Member

Choose a reason for hiding this comment

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

I think process_decl_or_create_unsupported resets preceding_comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fparser2_comment_test.py has some failures if I delete this line, so maybe not all exits of the method clears it?

self._process_decl_or_create_unsupported(
parent, parent.symbol_table, node, visibility_map,
statics_list, preceding_comments)
preceding_comments = []
Copy link
Member

Choose a reason for hiding this comment

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

Again, could you check whether this reset of preceding_comments is needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is needed to pass the tests.

UnsupportedFortranType)


def test_type_with_outside_reference(f2008_parser):
Copy link
Member

Choose a reason for hiding this comment

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

Please could you also add (or check for existing) test of a structure with a CONTAINS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As mentioned we have: test_derived_type_contains

@sergisiso
Copy link
Collaborator Author

@arporter This is ready for another review. I had to re-introduce the exclusion for fldread but it turns out this is because the issue was not due to derived type issue but due to a lhs-rhs dependency in one of those references, this is explored in an existing issue which I have updated with this case. The good news is that all obs_* files, that previously we had to blanked exclude, now work. Also the performance is back to where it was before #3266, meaning that we know need to check the datatype before extending arrays, but also that we manage to parse and understand all components that matter in order to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants