Skip to content
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

Merged
merged 7 commits into from
Mar 18, 2020
Merged

Fix some typo. Add more cases about integer hex oct range checking. #1916

merged 7 commits into from
Mar 18, 2020

Conversation

Shylock-Hg
Copy link
Contributor

@Shylock-Hg Shylock-Hg commented Mar 13, 2020

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?

@Shylock-Hg Shylock-Hg added the ready-for-testing PR: ready for the CI test label Mar 13, 2020
Copy link
Contributor

@laura-ding laura-ding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

$$ = new PrimaryExpression($1);
}
| MINUS INTEGER {
ifOutOfNegativeRange($2, @2);
Copy link
Contributor

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

}
}

void ifOutOfNegativeRange(const int64_t input,
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@Shylock-Hg Shylock-Hg linked an issue Mar 13, 2020 that may be closed by this pull request
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with == MAX_INTEGER

@@ -17,6 +17,8 @@ using TokenType = nebula::GraphParser::token;

static constexpr size_t MAX_STRING = 4096;

static constexpr size_t MAX_INTEGER = 9223372036854775808ULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change a name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ABS_MIN_INTEGER?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIN not MAX?

Copy link
Contributor

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.

Copy link
Contributor Author

@Shylock-Hg Shylock-Hg Mar 16, 2020

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, I agree.

@Shylock-Hg Shylock-Hg requested a review from laura-ding March 13, 2020 13:20
@codecov-io
Copy link

codecov-io commented Mar 14, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@250ae9e). Click here to learn what that means.
The diff coverage is 98.19%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1916   +/-   ##
=========================================
  Coverage          ?   86.93%           
=========================================
  Files             ?      636           
  Lines             ?    59913           
  Branches          ?        0           
=========================================
  Hits              ?    52084           
  Misses            ?     7829           
  Partials          ?        0
Impacted Files Coverage Δ
src/parser/test/ParserTest.cpp 100% <100%> (ø)
src/parser/test/ScannerTest.cpp 96.9% <100%> (ø)
src/parser/scanner.lex 91.77% <83.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 250ae9e...0ac8207. Read the comment docs.

@jude-zhu jude-zhu added this to the R201910_RC4 milestone Mar 16, 2020
Copy link
Contributor

@laura-ding laura-ding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

Copy link
Contributor

@dutor dutor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.

@dutor dutor merged commit ddb0ec4 into vesoft-inc:master Mar 18, 2020
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integer sementic conflict
5 participants