-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix some typo. Add more cases about integer hex oct range checking. #1916
Fix some typo. Add more cases about integer hex oct range checking. #1916
Conversation
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.
Thanks
src/parser/parser.yy
Outdated
$$ = new PrimaryExpression($1); | ||
} | ||
| MINUS INTEGER { | ||
ifOutOfNegativeRange($2, @2); |
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.
the INTEGER on here can’t out of the min of INTEGER,don't need ifOutOfNegativeRange
src/parser/parser.yy
Outdated
} | ||
} | ||
|
||
void ifOutOfNegativeRange(const int64_t input, |
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.
The scanner has guaranteed no more than 9223372036854775808. Negative Numbers do not need to be checked
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.
Hex/Oct don't guaranteed.
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.
So I plan to check hex/oct number length when lex.
src/parser/parser.yy
Outdated
void ifOutOfRange(const int64_t input, | ||
const nebula::GraphParser::location_type& loc) { | ||
if ((uint64_t)input == 9223372036854775808ULL) { | ||
throw nebula::GraphParser::syntax_error(loc, "out of range"); | ||
if ((uint64_t)input > 9223372036854775807ULL) { |
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.
replace with == MAX_INTEGER
src/parser/scanner.lex
Outdated
@@ -17,6 +17,8 @@ using TokenType = nebula::GraphParser::token; | |||
|
|||
static constexpr size_t MAX_STRING = 4096; | |||
|
|||
static constexpr size_t MAX_INTEGER = 9223372036854775808ULL; |
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.
change a name
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.
What name?
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.
ABS_MIN_INTEGER?
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.
MIN not MAX?
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.
MIN, ABS
is to describe the MIN_INTEGER
.
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 don't think it's clear, I think maybe MAX_ABS_INTEGER
better.
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, I agree.
Codecov Report
@@ Coverage Diff @@
## master #1916 +/- ##
=========================================
Coverage ? 86.93%
=========================================
Files ? 636
Lines ? 59913
Branches ? 0
=========================================
Hits ? 52084
Misses ? 7829
Partials ? 0
Continue to review full report at Codecov.
|
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.
Well done
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.
Well done.
…esoft-inc#1916) * Fix some typo. Add more cases about integer hex oct range checking. * Check the integer limit when lex. * Let the hex/oct scanner case more property. * Share the MAX_INTEGER in lex/parser. * Change the constant name Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
What changes were proposed in this pull request?
Add integer range checking cases about dec/hex/oct.
Fix the origin checking error which can't check hex/oct accurately
Fix some typo.
Why are the changes needed?
Add the checking to hex/oct to avoid if user store a number
+0xFFFFFFFFFFFFFFFF
we tell him it's negative, because now we filled the literal as uint64_t and cast to int64_t later.Does this PR introduce any user-facing change?
NO
How was this patch tested?