Repository navigation
Fix blink YodaStyle swapping parenthesized assignment after OperatorLinebreak - #226
Merged
Merged
Conversation
…daStyle
Moving a boolean operator to the next line blanked the operator tokens
with SetValue("") but left them in the stream. The zero-width Punct
tokens extended YodaStyle's operand scan past a closing paren, so a
parenthesized assignment "null !== ($p = ...)" was wrongly swapped to
"($p = ...) !== null", diverging from PHP ECS (laravel Gate.php).
Drop the blanked tokens after moving operators. Adds a regression test
and phase progress output to the parity harness.
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.
Problem
On the laravel parity corpus, blink diverged from PHP ECS on
src/Illuminate/Auth/Access/Gate.php(and others):Root cause
OperatorLinebreak, when moving a boolean operator to the next line, blanked the operator tokens withSetValue("")but left them in the stream. Those zero-widthPuncttokens then extendedYodaStyle's operand scan past the closing paren, defeating the guard that keeps a whole parenthesized group in place. As a result a parenthesized assignmentnull !== ($p = ...)was wrongly swapped to($p = ...) !== null.The bug only surfaced in the full pipeline (IsNull -> OperatorLinebreak -> YodaStyle) with the operator moved to line start, which is why isolated fixer tests passed.
Fix
Drop the blanked tokens after moving operators. The change is render-neutral (zero-width tokens produce no output), so it can only remove latent corruption, not alter correct output. The idempotency test confirms this.
Verification
go vet+gofmtpass; added a regression test.Also adds phase-progress logging to
blink/parity/run.shso the parity CI step is no longer silent during the long fix phase.