Repository navigation
Return errors from must list helpers for invalid inputs - #500
Open
ViktorBystrov72 wants to merge 1 commit into
Open
ViktorBystrov72 wants to merge 1 commit into
ViktorBystrov72 wants to merge 1 commit into
Conversation
Signed-off-by: Виктор Быстров <anatema@bk.ru>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
mustlist helpers are documented to return errors, but nil inputs currently panic inreflect.TypeOf(...).Kind().mustChunkalso panics or silently accepts nonpositive sizes, andmustSlicepanics on invalid bounds and on ordinary arrays passed through an interface.Validate these inputs before reflection or allocation, return the existing type errors for nil values, and make arrays addressable before slicing. Chunk counts use integer arithmetic. Valid slice reslicing up to capacity and existing empty-list results are preserved; the non-
mustwrappers still panic when their helper returns an error.Regression coverage includes all twelve affected nil-input helpers, zero/negative chunk sizes on empty and populated lists, invalid slice bounds, array slicing, and a valid capacity-based reslice. Thirty-two assertions fail on the base implementation and pass with the fix.
Validation on macOS arm64:
TZ=UTC go test -race -cover -count=1 ./...passes, with 85.7% coverage.TZ=UTC go test -race -cover -skip '^TestRound$' -count=1 ./...passes;go vet ./...,go build ./..., gofmt, andgit diff --checkalso pass.TestHtmlDatein the machine's local timezone andTestRoundunder Go 1.27.3 on arm64. UTC addresses the date test's existing timezone assumption; the rounding failure also reproduces on the base and is covered by the existing PR Prevent fused arithmetic from changing round results #488.