Repository navigation
Fix prepend! of a SentinelVector to itself - #138
Open
quinnj-bot[bot] wants to merge 2 commits into
Open
quinnj-bot[bot] wants to merge 2 commits into
quinnj-bot[bot] wants to merge 2 commits into
Conversation
Fails on main; passes with the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_prepend! grows the vector before reading the items, so prepend!(x, x) read the new uninitialized slots. Pass Base.unalias(x, items) so an aliased source is copied first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
A
SentinelVectorshould give the same answers as aVector{Union{T, Missing}}with the same values.prepend!(x, x)grewxfirst and then read the new, uninitialized front slots as the items to prepend. It returned leftover memory for bits types and threwUndefRefErrorforString:What changed
prepend!(x, items::AbstractVector)passesBase.unalias(x, items), so it copiesitemsfirst when it isxor a view ofx.Scope
append!was already correct for this case.Blast radius
Calls where
itemsdoes not share storage withxpay one identity check.Verification
mainand passes on this branch (Julia 1.12.6).Base.unaliascopies whenitemsisxor a view ofx, and passes other vectors through unchanged.ChainedVector,SentinelVector, andMissingVector, compared withVector) reports this mismatch onmainand not with the fixes applied.🤖 Generated with Claude Code