-
-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the int256 signed integer type #2351
Merged
Merged
Conversation
This file contains 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.
What I did
Add the
int256
type.How I did it
context
, I've added a new type primitive and definition forint256
. I also expanded the abstract numeric types to make it easier to support e.g. any signed integer type when dealing with builtin function inputs.functions
, I've modified the expected input types using the new absract types. Any function that previously expectedint128
can now receive bothint128
andint256
. This required a bit of weirdness in the abstract types so as to not rekt the old type system - I left a comment explaining what's happening, as types are removed fromparser
we'll eventually be able to remove that code.parser
I mostly removed type logic. I can into an issue around literals where anything that could be cast asint128
was cast as such. The best fix I found was to do away with parser-level type checking and just assume that if we made it this far, numeric types are allowed to interact. Where things got strange I left comments. It's again a case of, until types are fully removed from parser we need to be a bit hacky to make the old and new systems play nicely together.Overflow checks for
int256
math operations are consistent with those used in OpenZeppelin'sSignedSafeMath
library.Note that anywhere I removed a
parser
-level type check, I verified that the check is actually happening withincontext
and that the check was not being reached in coverage reports. We've hadcontext
in place for almost a year now, I feel pretty OK with trusting it and removing these redundant checks.How to verify it
Run the test suite. I've added test cases around
int256
math, unary operations, and usingconvert
to move into and out of the new type.Cute Animal Picture