-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Add type().min/max for enums #11847
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 type().min/max for enums #11847
Conversation
The test is failing and I am not sure why:
Any clues are welcome! |
libsolidity/ast/Types.h
Outdated
unsigned int memberValue(ASTString const& _member) const; | ||
size_t numberOfMembers() const; | ||
unsigned int minValue() const { return 0; } | ||
unsigned int maxValue() const { return static_cast<unsigned int>(numberOfMembers()); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max amount of members is 256 so this is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to subtract 1 from the size ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max amount of members is 256 so this is fine
Even then this should have an assert so that we find this in case the limit changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to subtract 1 from the size ;)
Hmm must have forgotten to push that, my local version has it already
58999f7
to
8771e93
Compare
a6d5c86
to
154f53f
Compare
154f53f
to
84c80ee
Compare
Please add changelog entry and documentation. |
84c80ee
to
c36df1a
Compare
Changelog.md
Outdated
### 0.8.8 (unreleased) | ||
|
||
Language Features: | ||
* Type System: Add ``type().min`` and ``type().max`` for enums |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Type System: Add ``type().min`` and ``type().max`` for enums | |
* Type System: Suppert ``type().min`` and ``type().max`` for enums. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppert :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did add the right spelling though :P
1fa0abd
to
60db3cc
Compare
60db3cc
to
df18075
Compare
df18075
to
0608761
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the dot ;-).
0608761
to
2b28f87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
fixes #11469