Conversation
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.
Decoding an oversized slice into an array that already contains values can panic after changing part of the destination. For example, decoding
[]int{1, 2, 3}into[2]int{7, 8}panics instead of returning the length error that a zero-valued array receives. Arrays containing slices also skip these checks. Invalid scalar inputs can panic, and a string can be incorrectly accepted as its character bytes.Check the input type and length before deciding whether to reuse the destination array. Invalid inputs now return the existing errors without changing that array, and weak conversions work regardless of its previous contents. Valid shorter inputs still preserve the remaining elements unless
ZeroFieldsis enabled.Regression tests cover populated arrays, arrays containing slices, weak conversions, nested-field errors and unchanged valid-input behavior. On Windows, the full shuffled suite passes on Go 1.18.10 and Go 1.27.1, with race detection on Go 1.27.1. Both builds and Go 1.27.1 vet pass, and the configured formatters report no changes.
Local limits: Go 1.18 vet reports the same two existing findings before and after this change; its race build cannot link with the local compiler. Golangci-lint 2.12.2 reports the same three existing
reflect.Ptrfindings on both revisions. The CI-pinned linter version and Linux matrix were not run locally.