Skip to content

Reverse SentinelVectors with missing values and an undef sentinel - #144

Open
quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/sentinelvector-reverse-unset
Open

quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/sentinelvector-reverse-unset

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Why

A SentinelVector should give the same answers as a Vector{Union{T, Missing}} with the same values. reverse threw for any String (or other non-bits) SentinelVector that holds a missing:

julia> s = SentinelVector{String}(undef, 3); s[1] = "a"; s[3] = "c";

julia> reverse(s)
ERROR: UndefRefError: access to undefined reference     # Vector gives ["c", missing, "a"]

With the default undef sentinel, a missing value is an unassigned slot in the parent array. reverse reversed the parent directly, which reads every slot.

What changed

  • For an undef sentinel, reverse copies the array and calls reverse! on it, which goes through getindex and setindex! and treats unassigned slots as missing. Other sentinels keep reversing the parent.

Scope

  • Both paths still return a SentinelVector with the same sentinel and value.

Blast radius

Only SentinelVectors with the undef sentinel change, and only by no longer throwing.

Verification

🤖 Generated with Claude Code

quinnj and others added 2 commits November 18, 2026 23:28
Fails on main; passes with the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the default undef sentinel (String and other non-bits element
types), missing values are unassigned parent slots. reverse reversed
the parent, which reads every slot and threw UndefRefError on the first
missing value. For an undef sentinel, copy the array and reverse! it
through getindex and setindex!, which treat unset slots as the value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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