Skip to content

Fix row stride for rectangular two-dimensional arrays - #61

Merged
zyedidia merged 1 commit into
zyedidia:masterfrom
ac1982:fix/rectangular-array-stride
Oct 12, 2026
Merged

zyedidia merged 1 commit into
zyedidia:masterfrom
ac1982:fix/rectangular-array-stride

Conversation

@ac1982

@ac1982 ac1982 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Array2D uses height instead of width as the row stride. A 4×2 array overwrites the end of its first row when filling the second; a 2×4 array panics for valid coordinates. Existing square-array tests mask this.

Use width consistently in Get/Set, Row/RowSpan and Fill. Add rectangular, single-row and single-column regression cases checking values, row slices, reversed spans, String, Copy, OfJagged and partial Fill. The original implementation reproduces both overwriting and an index-out-of-range panic.

Validation: full go test -race ./... and go vet ./... on Go 1.27.1, full tests on Go 1.19.13 (the CI series), Staticcheck 2026.2.1, formatting and git diff --check pass on Linux/arm64. The historical CI Staticcheck 2022.1.1 version was not run.

AI-assisted implementation and validation.

@zyedidia
zyedidia merged commit 9a78157 into zyedidia:master Oct 12, 2026
1 check passed
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.

2 participants