Fix sequence-ref to avoid unnecessary lookahead consumption#5341
Open
NoahStoryM wants to merge 7 commits intoracket:masterfrom
Open
Fix sequence-ref to avoid unnecessary lookahead consumption#5341NoahStoryM wants to merge 7 commits intoracket:masterfrom
sequence-ref to avoid unnecessary lookahead consumption#5341NoahStoryM wants to merge 7 commits intoracket:masterfrom
Conversation
Replace `#:unless` with `#:final` in `sequence-ref` to prevent unnecessary lookahead consumption from stateful sequences. The previous implementation would consume one additional element after reaching the target index, causing inconsistent behavior with sequences that have side effects.
sorawee
reviewed
Sep 23, 2025
Collaborator
|
I could be missing something, but does this accomplish what you want? |
Contributor
Author
|
I think this version looks correct, and it should behave as intended. Since this one matches the behavior of the original implementation, I’ll go ahead and use it for now. |
Collaborator
|
An issue with the |
Collaborator
|
Is this good to merge for the upcoming release? @mflatt |
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.
Checklist
Description of change
Fix
sequence-refto stop consuming extra elements from stateful sequences.Problem
The current implementation of
sequence-refuses#:unless (j . < . i)which causes the loop to continue after reaching the target index, leading to unnecessary consumption of an additional element from the sequence. See also #5338.Example