-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[BREAKING] Disallow trailing dot not followed by number #4172
Conversation
Missing syntax tests |
Why should versions like |
libsolidity/parsing/Scanner.cpp
Outdated
@@ -768,8 +768,14 @@ Token::Value Scanner::scanNumber(char _charSeen) | |||
scanDecimalDigits(); // optional | |||
if (m_char == '.') | |||
{ | |||
// A '.' has to be followed by a number. | |||
if (!isDecimalDigit(m_source.get(1))) |
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 think this should also use m_source.isPastEndOfInput
. To ensure it is tested, please add a test case of contract C { uint a = 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.
Please add tests to the SolidityScanner
file too.
Versions like |
Rebased |
test/tools/isoltest.cpp
Outdated
@@ -99,8 +99,6 @@ void SyntaxTestTool::printContract() const | |||
for (auto const& error: m_test->errorList()) | |||
if (error.locationStart >= 0 && error.locationEnd >= 0) | |||
{ | |||
assert(static_cast<size_t>(error.locationStart) <= source.length()); | |||
assert(static_cast<size_t>(error.locationEnd) <= source.length()); |
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.
This fails if the error is in the end of the file, that is, if the contract is incomplete.
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.
It would still be good to have these. What are the exact numbers? This could be a bug in the parser or scanner.
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 really don't know what happened, but I just ran it now to get the numbers and it didn't crash 😕
test/tools/isoltest.cpp
Outdated
@@ -99,8 +99,6 @@ void SyntaxTestTool::printContract() const | |||
for (auto const& error: m_test->errorList()) | |||
if (error.locationStart >= 0 && error.locationEnd >= 0) | |||
{ | |||
assert(static_cast<size_t>(error.locationStart) <= source.length()); | |||
assert(static_cast<size_t>(error.locationEnd) <= source.length()); |
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.
It would still be good to have these. What are the exact numbers? This could be a bug in the parser or scanner.
Squashed and rebased. |
test/libsolidity/SolidityScanner.cpp
Outdated
scanner.reset(CharStream(".5"), ""); | ||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); | ||
scanner.reset(CharStream(".5e10"), ""); | ||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); |
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 think these above should have another expectation for EOS
@chriseth please review |
There are optimiser test failures, not sure they are just a CI issue, so restarted it. |
@axic can you come to https://meet.jit.si/SolidityWeekly, please? |
See ethereum/solidity#4172. This unblocks parsing member access expressions where the primary expression can't consume the dot in order to parse the `.member` postfix expression.
…it since 0.5.0 (#891) See ethereum/solidity#4172. This unblocks parsing member access expressions where the primary expression can't consume the dot in order to parse the `.member` postfix expression.
Closes #3210.
The trick here is that version tokens are also read as numbers, so there it should be fine to have other stuff after a
.
. So if the parser sees something like1.
,1
is returned as a number token and parsing goes on with.
.