Repository navigation
fix(json): reject negative index in Decode.index - #176
Open
ranas-mukminov wants to merge 1 commit into
Open
ranas-mukminov wants to merge 1 commit into
ranas-mukminov wants to merge 1 commit into
Conversation
Member
There is a github action here that installs the gren compiler using devbox in order to run the tests. I'd love if you wrote a test that triggers this error message. The change itself looks good. |
Member
|
Also, are you able to setup git commit signing? |
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.
Fixes #45.
Decode.indexonly checkedindex >= value.length, so a negative index fell through tovalue[index](undefined). That produced a misleading error for most decoders, and returnedOkfor decoders that succeed on any value (e.g.index -1 (succeed ())on[1]).This adds a guard before the existing bounds check that rejects negative indices with a proper expecting error, mirroring the existing longer-array message style. No other decoder behavior changes.
Note: the Gren test suite is in Gren and needs the Gren compiler, which is not available in this environment, so the change was verified with
node --checkon the edited kernel file only, plus manual review of the surrounding_Json_runHelpindex case. Issues #46 (dict on null-prototype objects, already handled viaObject.hasOwn) and #80 (Zone docs, noBrowser.Envreference remains) were checked while researching this and appear already addressed in Gren, so they are not touched here.