Skip to content

Conversation

@sergisiso
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (b1c6d91) to head (9e8ebf4).
⚠️ Report is 36 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3247   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files         375      376    +1     
  Lines       53442    53531   +89     
=======================================
+ Hits        53397    53487   +90     
+ Misses         45       44    -1     

☔ 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 @hiker This is ready for review, it is another step into making the all references expressed in the PSyIR so that tools that expect/operate on References don't need edge cases.

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.

Nice, thanks Sergi.
The only concern I have is that, with this change, we now won't warn if a Symbol incorrectly gets added to the table of a Container. Can we tighten up on that?
I see you ran the integration tests so I won't do that again this time around.

try:
symtab = self.scope.symbol_table
except SymbolError:
symtab = SymbolTable()
Copy link
Member

Choose a reason for hiding this comment

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

Why is this branch necessary? Please add a comment.

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

for name in self.get_symbol_names():
var_accesses.add_access(Signature(name), AccessType.READWRITE,
self)
for child in self.children:
Copy link
Member

Choose a reason for hiding this comment

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

Comment please: all symbols accessed within the CodeBlock are captured as Reference nodes and stored as children of the CodeBlock node (or something).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added your words

self.ast_end = None
# Store the structure of the code block.
self._structure = structure
self._insert_representative_references()
Copy link
Member

Choose a reason for hiding this comment

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

Comment pls.

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

SymbolTable, SymbolError, UnresolvedInterface)


class CodeBlock(Statement, DataNode):
Copy link
Member

Choose a reason for hiding this comment

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

Please update the class docstring to record that it does now have children.

Copy link
Member

Choose a reason for hiding this comment

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

(I've checked the description of CodeBlocks in the documentation and it doesn't require any updating.)

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

continue
result.append(node.string)
# Precision on literals requires special attention since they are just
# stored in the tree as str (fparser/#456).
Copy link
Member

Choose a reason for hiding this comment

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

Not yours but L263 is not covered by the associated test file. Perhaps one for @LonelyCat124 to fix while he's looking at directives?

# s symbol should not be in my_mod
with pytest.raises(KeyError):
psyir.children[0].symbol_table.lookup("s")
# FIXME: explain
Copy link
Member

Choose a reason for hiding this comment

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

Yes please :-)

'''
fake_parent, fparser2spec = process_where(
"WHERE (ptsu(myfunc(), :, :) /= 0._wp)\n"
"WHERE (ptsu(unres, :, :) /= 0._wp)\n"
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason for this change?

assert "myifblock" not in sym_names
assert "this_is_true" in sym_names
assert "that_is_true" in sym_names
refs = block.walk(Reference)
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 check that these refs are immediate children of the CodeBlock (as this is new).

Your use of 'virtual refs' to describe them did make me wonder whether we should have a new VirtualReference subclass of Reference but I'm not sure that buys us anything other than making it clear that these aren't "real" references.

''' Tests the infer_sharing_attributes() method when some of the loops have
Codeblocks inside it. We check that the infer_sharing attribute analysis
succeed by assuming worst case.
potentially hidden references (e.g. inside codeblocks or loop varialbes).
Copy link
Member

Choose a reason for hiding this comment

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

"variables"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

loop = psyir.walk(Loop)[loop_idx]
# Make sure that the write statements inside the loop are CodeBlocks,
# otherwise we need a new test example
assert loop.has_descendant(nodes.CodeBlock)
Copy link
Member

Choose a reason for hiding this comment

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

We still need something like this check - probably has to be a walk now.

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