Skip to content

(closes #2642) Support structure type extends and contains - #3563

Open
sergisiso wants to merge 13 commits into
masterfrom
2642_extend_structure_type
Open

(closes #2642) Support structure type extends and contains#3563
sergisiso wants to merge 13 commits into
masterfrom
2642_extend_structure_type

Conversation

@sergisiso

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (72527a7) to head (83e6657).
⚠️ Report is 77 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #3563    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          397       397            
  Lines        55775     56023   +248     
==========================================
+ Hits         55775     56023   +248     

☔ View full report in Codecov by Harness.
📢 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 sergisiso self-assigned this Aug 20, 2026
@sergisiso
sergisiso deployed to integration August 20, 2026 15:15 — with GitHub Actions Active
@sergisiso

Copy link
Copy Markdown
Collaborator Author

@arporter @LonelyCat124 This is ready to review, it is a necesarry step to read the metadata using psyir. Wihtout this the embedded metadata ends up in an UnsupportedFortranType, and we still would need to parse it as a string.

It seems that Rupert started this path of parsing the metadata from the UnsupportedType as a string, at the moment I convert the new datatype back to an string and then pass it to existing metadata parsing to keep coverage of the existing tests (which feels odd). The previous PR adding this this feature #2644 also hit the same problem.

However, I have a follow up PR that converts the metadata parsing to take proper PSyIR (removing the need of fparser1 and string metadata parsing) and the code that lose coverage can be removed altoghether. But the resulting PR was huge. In fact I cut this branch to make the whole review more manegable.

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sergisiso From an implementation perspective I think I'm mostly ok with this (if I understood it correctly). However, there are some areas lacking comments, some missing typehints (some of which are old missing but you've modified the function) and some typehints which I believe are wrong. See comments inline.

# replace this
declaration = FortranWriter().gen_typedecl(
symbol, include_visibility=False)
# Preserve the spelling

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Preserve the spelling
# Preserve the casing

?

str(self.name), UnsupportedFortranType(self.fortran_string()))

@staticmethod
def create_from_psyir(symbol):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typehints here please.

'''Create a new instance of GOceanKernelMetadata populated with
metadata from a kernel in language-level PSyIR.

:param symbol: the symbol in which the metadata is stored \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove any remaining \ from the docstring.

f"'{coarse_function_space}'"))

@staticmethod
def create_from_psyir(symbol):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typehints

'''Create a new instance of LFRicKernelMetadata populated with
metadata from a kernel in language-level PSyIR.

:param symbol: the symbol in which the metadata is stored \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove \s

f"The visibility of a procedure component of a StructureType "
f"must be an instance of 'Symbol.Visibility' but got "
f"'{type(visibility).__name__}'")
if (initial_value is not None and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we just do if (initial_value and ...?


return True

def replace_symbols_using(self, table_or_symbol):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

type/return hints

preceding_comment=component.preceding_comment,
inline_comment=component.inline_comment)

for component in list(self.procedure_components.values()):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Brief comment explaining the block, e.g.

# Add the procedure components and setup the intial values of the components where appropriate

Or similar.

component.name, new_type, component.visibility,
initial_value, component.preceding_comment,
component.inline_comment)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

# Maintain the inheritance if necessary

or similar.

assert "Expected a DataTypeSymbol but found a str." in str(info.value)
metadata = GOceanKernelMetadata.create_from_psyir(symbol)
assert METADATA in metadata.fortran_string()
assert METADATA.upper() in metadata.fortran_string().upper()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why does the check require the upper case change now? If there's a specific reason then please add a comment so its clear as to why (since PSyclone should be consistent in its output)

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