Skip to content

Drop JSON constants from bitwise-or structurally in JsonConstCleaner - #410

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-jsonconst-robust-drop
Oct 18, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-jsonconst-robust-drop

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

JsonConstCleaner decided which bitwise-or operand to drop from the ORIGINAL_NODE attribute (isTransformed()). That attribute is not reliably present on re-decorated inner nodes, so a nested chain such as A | B | C | D | E | JSON_THROW_ON_ERROR could collapse to a single 0 instead of dropping only the target constant.

The chain is now flattened and the target constants are dropped structurally, independent of ORIGINAL_NODE. Output is unchanged on the current engine - the full downgrade test suite passes with no fixture changes.

This also makes the cleaning stable when a rule runs more than once over the same node, which the upcoming rector-src node-traverser simplification needs.

The bitwise-or cleaning decided what to drop from the ORIGINAL_NODE
attribute, which is not reliably present on re-decorated inner nodes, so
a nested chain could collapse to a single 0. Flatten the chain and drop
the target constants structurally instead; output is unchanged.
@TomasVotruba
TomasVotruba merged commit 26e8fc3 into main Oct 18, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the tv-jsonconst-robust-drop branch October 18, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant