Skip to content

Reject incomplete multidimensional input in make - #77

Draft
quinnj wants to merge 1 commit into
mainfrom
fix/multidimensional-input-shape
Draft

quinnj wants to merge 1 commit into
mainfrom
fix/multidimensional-input-shape

Conversation

@quinnj

@quinnj quinnj commented Sep 22, 2026

Copy link
Copy Markdown
Member

StructUtils.make(Matrix{String}, [["a", "b"], ["c"]]) currently returns an array with an unassigned cell. Shape discovery uses the first nested branch, and bounds checks cannot detect cells omitted by later branches.

Track initialized cells during multidimensional make construction and reject incomplete coverage before returning the new array. Preserve reordered/repeated integer keys, ragged vector-valued leaves, collapsed singleton axes, and partial updates of existing arrays. Use dimension-specialized tuple indices to avoid the existing dynamic-splat allocations.

For a warmed 32×32 integer matrix, total allocations change from 74,080 to 8,784 bytes. An indexing-only control allocates 8,480 bytes: the coverage check adds 304 bytes. The check allocates one bit per element and scans that bitmap once; it does not traverse the source again.

Validation: 68 focused checks pass with bounds checks disabled; Julia 1.9.4 passed 679 checks including its expected trim skip; Julia 1.12.7 passed all 678 ordinary checks. Independent review passed 13 further controls. The local Julia 1.12 trim executable compiled but became stuck in macOS UE state and did not exit after termination; that run is blocked, not passed. Repository CI still runs the unchanged trim check.

Draft/API boundary: this fixes make(Type, source). The separate make!(Type, source) path calls the public initialize hook, then updates its result. Its default initializer can still leave cells unassigned for ragged input, while custom initializers can validly supply defaults for partial updates. Preserving that hook needs a separate initializer-contract decision; this PR does not claim to fix that entrypoint or change it silently. Existing-instance make! stays unchanged. PR #76 independently covers fixed-size vectors.

Co-authored by Codex

This branch has not been deployed

No deployments
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