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
Handle move blocks within a module which is changing the index #30232
Conversation
Add a method for checking if the From and To addresses in a move statement are only changing the indexes of modules relative to the statement module. This is needed because move statement nested within the module will be able to match against both the From and To addresses, causing cycles in the order of move operations.
Implied moves in nested modules were being skipped
7587a28
to
b23595f
Compare
a4cba4d
to
99704ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me!
// ancestor module is only changing the index of a nested module, any | ||
// nested move statements are going to match both the From and To address | ||
// when the base name is not changing, causing a cycle in the order of | ||
// operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a bit of trouble understanding the previous block of code and its comment without the context of this paragraph here. I think it would have been easier to follow if this paragraph was before line 247, setting the scene for why we care about ancestor modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I can move that around and group the checks together.
Changing only the index on a nested module will cause all nested moves to create cycles, since their full addresses will match both the From and To addresses. When building the dependency graph, check if the parent is only changing the index of the containing module, and prevent the backwards edge for the move.
7a5c1f3
to
75ef61c
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
When a move statement is only changing the index of a module, any moves within that module would result in cycles, because both the absolute
From
andTo
addresses would match both of the parent module'sFrom
andTo
address.For example, changing the index of a module named
count
results in a afrom->to
of:And changing the count of a resource nested within
module.count
results in:Because
module.count[*]
matches both theFrom
andTo
addresses of the parent, the edges would be added in both directions resulting in a cycle.The graph we actually want in this case looks like
with a connection only from the inner move to the outer move, which matches the same order of operations when the outer module is changing the name entirely. We achieve this by checking if the dependent move statement is only changing the module index with a new
from.MoveModuleReIndex(to)
method, and skip adding the graph edge.Fixes #30208
While not contributing to the cycle, it was noticed in #30208 that
impliedMoveStatements
was not correctly calling itself recursively, which is also fixed and tested by this PR.