Skip to content

Check fixed-size vector input lengths - #76

Merged
quinnj merged 1 commit into
mainfrom
audit/collection-lifting
Sep 23, 2026
Merged

quinnj merged 1 commit into
mainfrom
audit/collection-lifting

Conversation

@quinnj

@quinnj quinnj commented Sep 22, 2026

Copy link
Copy Markdown
Member

StructUtils.make(SVector{2,Int}, [1]) currently returns a vector with an uninitialized second slot. The shared fixed-size vector writer also uses @inbounds without checking excess input.

Check each write against the target size, then check the final count before constructing the result. Both short and long input now throw DimensionMismatch. The checks use the existing single pass, including for iterators without a known length. The separate multidimensional path is unchanged.

Validation: the new regressions failed 14 checks against the original implementation with bounds checks forced. All 32 now pass with bounds checks disabled. They cover immutable/mutable vectors, numeric/reference elements, empty input, exact/short/long lengths, unknown-length iterators, and custom style hooks. Full suites passed 649 checks on Julia 1.12.7 (including 7 trim checks) and 643 on Julia 1.9.4. Allocations were unchanged for five valid-input cases. Oversized input on the original code was tested only with forced bounds checks.

Co-authored by Codex

@quinnj
quinnj merged commit 2d58707 into main Sep 23, 2026
9 checks passed
@quinnj
quinnj deleted the audit/collection-lifting branch September 23, 2026 01:36
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