Skip to content

Keep empty chained vectors valid when resizing to zero - #128

Merged
quinnj merged 1 commit into
mainfrom
maintenance/chainedvector-empty-resize
Oct 15, 2026
Merged

quinnj merged 1 commit into
mainfrom
maintenance/chainedvector-empty-resize

Conversation

@quinnj

@quinnj quinnj commented Oct 3, 2026

Copy link
Copy Markdown
Member

Resizing an already empty ChainedVector to zero enters the shrinking branch, grows its chunk and offset storage to one slot, and throws UndefRefError while reading the unassigned chunk. Return early when the requested length equals the current length so a no-op resize keeps the vector valid.

Add 39 regression checks for newly created empty vectors, empty input chunks, empty!, pop!, repeated shrinking to zero, and reuse through push! and append!. Also cover a no-op resize on a nonempty vector and rejection of negative lengths.

Validation: the unchanged base reproduces UndefRefError and leaves one unassigned chunk slot. The complete suite passes on Julia 1.12.6, including all 39 new checks. A separate 14-check usability probe passes on Julia 1.6.7.

Co-authored by Codex

AI disclosure: This work was prepared with assistance from OpenAI Codex.

Return before modifying storage when the requested length is unchanged.
Verify empty vectors remain usable after resizing, pushing, and appending.

Co-authored by Codex

AI disclosure: This work was prepared with assistance from OpenAI Codex.
@quinnj quinnj mentioned this pull request Oct 15, 2026
@quinnj
quinnj merged commit 3d2597d into main Oct 15, 2026
4 checks passed
@quinnj
quinnj deleted the maintenance/chainedvector-empty-resize branch October 15, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant