Repository navigation
fix(engine,postprocess): align binary chains and drifted expressions - #248
Merged
Merged
Conversation
Deleting an operand from a binary chain like (A || B) || C let inner binary expressions grab B || C across the operator, shifting the chain mapping off by one level. Meanwhile, edits earlier in the file drifted statement row numbers, causing stationary expressions inside untouched statements to fail absolute line checks and emit false moves. - engine: reject inner binary expression matches when shared operands cross operator sides and an unmapped parent binary expression keeps them on the same side, preventing off-by-one chain misalignment - postprocess: use structural stationarity and statement-relative row offsets so line drift from earlier edits doesn't trigger false moves - tests: add coverage for binary chain truncation and drifted stationary expressions, and refresh integration golden fixtures
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
(A || B) || Cdown toB || C, BottomUp let the inner(A || B)grabB || Cacross the operator. The parent node was the one that actually matched, but the inner node grabbed it first and threw off the rest of the chain.StartRow). If lines were added earlier in the file, untouched statements shifted down. Expressions inside them failed the line check and showed up as false moves.What Changed
internal/engine/bottom-up.go: AddedhasCrossSideOperatorMismatchso inner binary expressions don't steal matches across an operator when their unmapped parent already matches that side.internal/postprocess/normalize.go: AddedisStatementStationaryto check if a statement actually stayed put structurally, ignoring line shifts from edits earlier in the file.internal/postprocess/normalize.go: MadeisStationaryExpressionMoveandrequiredMoveThresholdmeasure drift relative to the enclosing statement instead of the whole file.