-
-
Notifications
You must be signed in to change notification settings - Fork 686
Fix sequence-ref
to avoid unnecessary lookahead consumption
#5341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
I could be missing something, but does this accomplish what you want?
|
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. |
An issue with the |
Is this good to merge for the upcoming release? @mflatt |
Checklist
Description of change
Fix
sequence-ref
to stop consuming extra elements from stateful sequences.Problem
The current implementation of
sequence-ref
uses#: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