mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Looking pragma operators per range and not per tokens.
Add 3 invalid tests and 2 valid tests
This commit is contained in:
parent
3a4a504c42
commit
ed7123c8df
@ -208,7 +208,10 @@ void SemVerMatchExpressionParser::parseMatchExpression()
|
||||
range.components.push_back(parseMatchComponent());
|
||||
if (currentToken() == Token::Sub)
|
||||
{
|
||||
if (containPrefixingToken())
|
||||
nextToken();
|
||||
range.components.push_back(parseMatchComponent());
|
||||
|
||||
if (TokenTraits::isPragmaOp(range.components[0].prefix) || TokenTraits::isPragmaOp(range.components[1].prefix))
|
||||
{
|
||||
solThrow(
|
||||
SemVerError,
|
||||
@ -217,8 +220,6 @@ void SemVerMatchExpressionParser::parseMatchExpression()
|
||||
}
|
||||
|
||||
range.components[0].prefix = Token::GreaterThanOrEqual;
|
||||
nextToken();
|
||||
range.components.push_back(parseMatchComponent());
|
||||
range.components[1].prefix = Token::LessThanOrEqual;
|
||||
}
|
||||
else
|
||||
@ -332,11 +333,3 @@ void SemVerMatchExpressionParser::nextToken()
|
||||
++m_pos;
|
||||
m_posInside = 0;
|
||||
}
|
||||
|
||||
bool SemVerMatchExpressionParser::containPrefixingToken() const
|
||||
{
|
||||
if (std::find_if(m_tokens.begin(), m_tokens.end(), TokenTraits::isPragmaOp) != m_tokens.end())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ private:
|
||||
char nextChar();
|
||||
Token currentToken() const;
|
||||
void nextToken();
|
||||
bool containPrefixingToken() const;
|
||||
|
||||
std::vector<Token> m_tokens;
|
||||
std::vector<std::string> m_literals;
|
||||
|
@ -0,0 +1,3 @@
|
||||
pragma solidity <0.8.17 - 0.8.20;
|
||||
// ----
|
||||
// ParserError 1684: (0-33): Invalid version pragma. You cannot use operators (<, <=, >=, >, ^) with version ranges (-).
|
@ -0,0 +1,3 @@
|
||||
pragma solidity 0.8.17 - >0.8.20;
|
||||
// ----
|
||||
// ParserError 1684: (0-33): Invalid version pragma. You cannot use operators (<, <=, >=, >, ^) with version ranges (-).
|
@ -0,0 +1,3 @@
|
||||
pragma solidity 0.8.14 || 0.8.17 - >0.8.20;
|
||||
// ----
|
||||
// ParserError 1684: (0-43): Invalid version pragma. You cannot use operators (<, <=, >=, >, ^) with version ranges (-).
|
@ -0,0 +1,2 @@
|
||||
pragma solidity 0.8.17 - 0.8.20;
|
||||
// ----
|
@ -0,0 +1,2 @@
|
||||
pragma solidity <0.8.15 || 0.8.17 - 0.8.20;
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user