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

refactoring: Move nested modules #30233

Merged
merged 1 commit into from Dec 22, 2021
Merged

Conversation

alisdair
Copy link
Member

When applying module moved statements by iterating through modules in state, we previously required an exact match from the moved statement's from field and the module address. This permitted moving resources directly inside a module, but did not recur into module calls within those moved modules.

This commit moves that exact match requirement so that it only applies to moved statements targeting resources. In turn this allows nested modules to be moved.

As of this commit, we are relying on the logic in ModuleInstance.MoveDestination() to control whether or not a given module instance is relevant to a moved statement. This method will return a false match result if the move statement doesn't apply:

// MoveDestination considers a an address representing a module
// instance in the context of source and destination move endpoints and then,
// if the module address matches the from endpoint, returns the corresponding
// new module address that the object should move to.
//
// MoveDestination will return false in its second return value if the receiver
// doesn't match fromMatch, indicating that the given move statement doesn't
// apply to this object.

Fixes #30197

When applying module `moved` statements by iterating through modules in
state, we previously required an exact match from the `moved`
statement's `from` field and the module address. This permitted moving
resources directly inside a module, but did not recur into module calls
within those moved modules.

This commit moves that exact match requirement so that it only applies
to `moved` statements targeting resources. In turn this allows nested
modules to be moved.
@alisdair alisdair added cli 1.1-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged labels Dec 21, 2021
@alisdair alisdair requested a review from a team December 21, 2021 21:47
@alisdair alisdair self-assigned this Dec 21, 2021
@alisdair alisdair merged commit f772cb0 into main Dec 22, 2021
@alisdair alisdair deleted the alisdair/move-nested-modules branch December 22, 2021 15:22
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.1-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged cli
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moved Block doesn't move nested modules in modules
2 participants