Fix int/uint interoperation to conform to de-facto expectations of other clients#215
Merged
philhofer merged 4 commits intotinylib:masterfrom Jan 30, 2018
Merged
Conversation
Contributor
|
I like this, but I don't see why ReadUint64 needs to be extended to signed integers. It's unlikely that feature will ever come in useful to anyone. |
Contributor
Author
|
If it doesn't hurt, and it works, why not? The spec is totally unclear about this one way or the other. What's to stop some client from implementing it the other way, and who would we be to say they were wrong? |
philhofer
requested changes
Jan 29, 2018
Member
philhofer
left a comment
There was a problem hiding this comment.
Happy to merge this once you get the build passing.
msgp/read_bytes_test.go
Outdated
| failBits int | ||
| errCheck func(err error, failBits int) bool | ||
| }{ | ||
| {math.MaxInt64, i32, 32, overflowErr}, |
Member
There was a problem hiding this comment.
these need explicit casts in order to make the 386 build pass
Contributor
Author
|
Oops, yep, sorry about that. I've fixed it up and it's passing on my machine with |
philhofer
approved these changes
Jan 30, 2018
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.
Been running this in production for a while now. This fixes #134 to meet the behaviour of other clients, which encode non-negative integers as unsigned regardless of whether the originating type is signed.
It raises an error on underflow or overflow and is tested pretty thoroughly (though I'm always happy to add more).
This change is