Skip to content

Match Vector's index rules in MissingVector insert!, deleteat!, and similar - #141

Open
quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/missingvector-index-rules
Open

quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/missingvector-index-rules

Conversation

@quinnj-bot

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

Copy link
Copy Markdown

Why

A MissingVector should follow the same index rules as a Vector{Missing}. It did not in three places:

julia> deleteat!(MissingVector(3), [1, 1])     # Vector throws ArgumentError
1-element MissingVector:
 missing

julia> insert!(MissingVector(2), 3, missing)   # Vector appends
ERROR: BoundsError: attempt to access 2-element MissingVector at index [3]

julia> hcat(MissingVector(2), [missing, missing])   # Vector gives a 2x2 Matrix
ERROR: BoundsError: attempt to access 2-element MissingVector at index [1:2, 2:2]

deleteat! with repeated or unsorted indices silently deleted the wrong number of elements. insert! rejected the append position. similar(x, Missing, dims) ignored every dimension after the first, so hcat wrote into a vector.

What changed

  • deleteat!(x, inds) checks that indices are sorted, unique, and in bounds, and throws the same errors as Vector.
  • insert!(x, length(x) + 1, missing) appends.
  • similar(x, Missing, dims) returns a MissingVector only for one dimension and falls back to Base otherwise.

Scope

  • These are three separate checks in MissingVector. Each one now matches Vector.

Blast radius

Callers that passed repeated or unsorted indices to deleteat! now get an error instead of a wrong length.

Verification

🤖 Generated with Claude Code

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…imilar

deleteat! deleted once per given index without checking order or
duplicates, insert! rejected the append position, and similar(x,
Missing, dims) ignored all but the first dimension, which broke hcat.
Validate deleteat! indices like Vector, accept length(x) + 1 in
insert!, and keep the MissingVector method of similar to one dimension.

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