Ensure multiple --value(…) or --modifier(…) calls don't delete subsequent declarations #17273
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 a bug in the handling of
@utility. Essentially if you had a declaration where you used a--modifier(…)and a--value(…)and both caused the declaration to be removed, the declaration after the current one would be removed as well.This happened because 2 reasons:
--modifier(…), we didn't stop the walk and kept going.replaceWith(…)code allows you to call the function multiple times but immediately mutates the AST. This means that if you call it multiple times that you are potentially removing / updating nodes followed by the current one.E.g.:
If this is used as
mask-r-10%, then the first definition of--mask-rightis kept, but the second definition of--mask-rightis deleted because both--modifier(integer)and--value(integer)do not result in a valid value.However, the
mask-imagedeclaration was also removed because thereplaceWith(…)function was called twice. Once for--modifier(integer)and once for--value(integer).Test plan
replaceWith(…)multiple times.