Repository navigation
experiment: remove shouldSkipCurrentNode guard - #8589
Closed
TomasVotruba wants to merge 1 commit into
Closed
TomasVotruba wants to merge 1 commit into
TomasVotruba wants to merge 1 commit into
Conversation
Drops the hard skip that bails out before refactor() when a node was already rectified by the same rule or just reprinted without a refreshed scope. Breaks ChangeSwitchTernaryTest: a rule firing on a freshly reprinted Expression node hits ScopeFetcher::fetch() on a scopeless node and throws 'Scope not available'. The guard was the safety net for that case (and for consecutive CREATED_BY_RULE re-application loops).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Experiment: what breaks if we remove the
shouldSkipCurrentNodeguard?Removed from
RectorRunner::run():Result
ChangeSwitchTernaryTestfails:Why
The guard delegates to
RectifiedAnalyzer::hasRectified(), which covers two cases:CREATED_BY_RULE- same rule re-applies to a node it just created (infinite re-apply loop).Case 2 is the one that breaks. When a rule reprints a node (switch -> match here), the new
Expressionnode has no scope yet. The guard skips it beforerefactor(). Without the guard, a rule subscribing to that node runs, callsScopeFetcher::fetch()on a scopeless node, and throws.tests/Issues/ChangeSwitchTernaryexists precisely to pin this behavior.Alternatives to handle it differently
ScopeFetchernever sees a scopeless node) - heavier, defeats the skip's purpose.Current guard is the cheapest correct approach. Draft - not for merge, demonstrates the finding.