[BREAKING] Disallow trailing dot not followed by number#4172
[BREAKING] Disallow trailing dot not followed by number#4172
Conversation
|
Missing syntax tests |
Why should versions like |
libsolidity/parsing/Scanner.cpp
Outdated
| if (m_char == '.') | ||
| { | ||
| // A '.' has to be followed by a number. | ||
| if (!isDecimalDigit(m_source.get(1))) |
There was a problem hiding this comment.
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.
axic
left a comment
There was a problem hiding this comment.
Please add tests to the SolidityScanner file too.
|
Versions like |
|
Rebased |
| 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.
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.
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.
I really don't know what happened, but I just ran it now to get the numbers and it didn't crash 😕
| 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.
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. |
| 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.
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 argotorg/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 argotorg/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 argotorg/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.,1is returned as a number token and parsing goes on with..