Conversation
…ge index AsyncSeq.removeAt and AsyncSeq.updateAt previously silently returned the source sequence unchanged when the index was >= the sequence length, which is inconsistent with List.removeAt, Array.removeAt, and AsyncSeq.insertAt. After the enumeration loop, check that the index was actually reached; if not (i.e. i <= index at end), raise ArgumentException matching the message used by AsyncSeq.insertAt. Adds 6 new tests covering out-of-range and boundary indices. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
approved these changes
Apr 20, 2026
2 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
AsyncSeq.removeAtandAsyncSeq.updateAtsilently returned the source sequence unchanged when the given index was ≥ the sequence length. This inconsistency with the rest of the F# standard library could lead to subtle bugs.Root Cause
The implementations iterated the sequence and simply skipped the operation when the index was never reached, with no post-loop validation:
Fix
After the enumeration loop, check whether
i <= index(meaning the element atindexwas never visited) and raiseArgumentExceptionwith the same message already used byAsyncSeq.insertAt:Consistency
List.removeAtArray.removeAtAsyncSeq.insertAtAsyncSeq.removeAt(before)AsyncSeq.updateAt(before)AsyncSeq.removeAt(after)AsyncSeq.updateAt(after)Trade-offs
This is technically a breaking change for any code that relied on the (buggy) silent-ignore behaviour. However, that behaviour was clearly unintentional and inconsistent with every comparable function.
Test Status
✅ Build: succeeded (pre-existing warnings only — no new warnings)
✅ Tests: 418/418 passed (7 new tests added: 3 for
removeAtout-of-range, 3 forupdateAtout-of-range)