bugfix!: over advancing in Cursor::advance_skipping_shared#162
Open
ParkMyCar wants to merge 2 commits into
Open
bugfix!: over advancing in Cursor::advance_skipping_shared#162ParkMyCar wants to merge 2 commits into
Cursor::advance_skipping_shared#162ParkMyCar wants to merge 2 commits into
Conversation
Owner
|
Thanks for the PR. I'm a little bothered by how complicated the looping becomes. For example, the following pattern is much simpler and seems pretty much the same: But the bigger thing that's bothering me actually predates this patch: why do the existing |
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.
Bug
When
Cursor::advance_skipping_sharedfinds equal leaves from the two cursors being compared, the index 0 element of the next non-shared leaf is skipped.The buggy behavior that causes this issue is:
CursorstoNoneand update the respective stacks to the next non-shared leaf.next()on both cursors, now referencing index 0 of the non-shared leavesskipped_any == falseand the leaves are not shared.next()on both cursors again, advancing both cursors to index 1 (the bug)Summary
The first commit of this PR is a failing test that exhibits the bug, the second commit are the requires changes to fix it.
AI disclosure: I didn't see any references to AI usage in your code of conduct, but wanted to callout that I used Claude to help me root cause the issue and implement a fix. I reviewed the change in the context of the codebase, and to the best of my knowledge this is the right fix, but wanted to be transparent in my use of AI :)
Fixes #161