Fix infinite loop when using @variant inside @custom-variant that points to another @custom-variant
#19633
+93
−1
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.
This PR fixes an infinite loop when you use a
@variantinside of a@custom-variant, where the@variantused is another@custom-variant.The issue stems from the fact that a
@custom-variantcan use a@slotthat we have to replace with the proper AST nodes. However in this setup, the AST nodes will include a@slotnode as well, which causes us to replace the@slotagain, and so on, causing an infinite loop.The solution here is to replace the
@slotnodes and then skip walking the nodes that were just inserted. This does mean that we end up with a@slotnode in the final AST but that's not a real issue because that will get replaced later when handling the next@custom-variant.Test plan
Thanks @wongjn for your initial debugging help and providing a test case as well!
Fixes: #19618