[Repo Assist] Fix CircularBuffer.Enqueue(array) - head pointer advances by count, not 1#233
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Conversation
When enqueueing an array of count elements, the head pointer was only advanced by 1 instead of count, causing subsequent array enqueues to overwrite incorrect positions in the buffer. The fix separates the start position calculation from the head update: - startPos = (head + 1) % bufferSize (where writing begins) - head = (head + count) % bufferSize (where head ends after writing) Also enables the three ptest tests that were previously pending due to this bug, confirming they now pass. Closes #125 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
25 tasks
Contributor
|
@gdziadkiewicz Over to you :) |
Contributor
|
@gdziadkiewicz Repo Assist creates all PRs in draft mode. There is a CI trigger in place so CI will run automatically. If it's green you can usually take them out of draft mode and assess. |
This was referenced Mar 10, 2026
[Repo Assist] test: add Seq module coverage for 7 untested functions; fix pending Seq.tail test
#244
Draft
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.
Closes #125
Root Cause
In
CircularBuffer.Enqueue(value: _[], offset, count), theheadpointer was unconditionally advanced by 1, regardless of how many elements were being enqueued:This meant that after enqueueing an array of N elements,
headpointed to the start of the written region, not the end. Subsequent enqueue operations then computed the wrong start position, causing data to be written to incorrect buffer locations and thetailpointer to be miscalculated.Fix
Separate the start-position calculation from the head update:
For
count = 1(single-element enqueue, which delegates here) the behaviour is identical to before.Changes
src/FSharpx.Collections/CircularBuffer.fs— fix the head advancement logictests/FSharpx.Collections.Tests/CircularBufferTests.fs— promote the threeptest(pending/skipped) tests totestsince they now passTest Status
✅
FSharpx.Collections.Tests: 709 passed, 3 ignored, 0 failed (includes the three newly-enabled CircularBuffer array tests)FSharpx.Collections.Experimental.Tests: killed with exit code 137 (OOM) — this is a pre-existing infrastructure issue unrelated to this change (see issues #115 and #116).