Repository navigation
Conversation
find reports every missing array index as the array length, so an add at /5 on a two-element array appended the value. RFC 6902 section 4.1 requires an error unless the index equals the length or the token is "-". Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
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.
Summary
Value.Patchtreated anaddwhose array index was past the end as an append.findreports every missing index as the array length, so/5on a two-element array wrote the value at the end. RFC 6902 section 4.1 requires an error in that case. An index equal to the length, and the-token, still append. The array is left unchanged when the index is past the end.Fixes #52.
Test plan
go test -count=1 ./.../5on[1,2]returned no error and produced[1,2,3]. After the check, that call returns the out-of-range error and the array stays[1,2]. Restoring the old insert made that case fail again, and putting the check back passed it. An index equal to the length and the-token still append.