Merge pull request #10655 from ethereum/semver-empty

Mark the empty version pragma as invalid
This commit is contained in:
Alex Beregszaszi
2021-01-04 20:09:33 +00:00
committed by GitHub
4 changed files with 12 additions and 3 deletions
+3
View File
@@ -151,6 +151,9 @@ optional<SemVerMatchExpression> SemVerMatchExpressionParser::parse()
{
reset();
if (m_tokens.empty())
return nullopt;
try
{
while (true)
+5 -2
View File
@@ -24,6 +24,7 @@
#pragma once
#include <liblangutil/Token.h>
#include <libsolutil/Assertions.h>
#include <string>
#include <optional>
@@ -84,9 +85,11 @@ struct SemVerMatchExpression
class SemVerMatchExpressionParser
{
public:
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals):
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals):
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
{}
{
solAssert(m_tokens.size() == m_literals.size(), "");
}
/// Returns an expression if it was parseable, or nothing otherwise.
std::optional<SemVerMatchExpression> parse();
+1 -1
View File
@@ -204,7 +204,7 @@ ASTPointer<PragmaDirective> Parser::parsePragmaDirective()
nodeFactory.markEndPosition();
expectToken(Token::Semicolon);
if (literals.size() >= 2 && literals[0] == "solidity")
if (literals.size() >= 1 && literals[0] == "solidity")
{
parsePragmaVersion(
nodeFactory.location(),
@@ -0,0 +1,3 @@
pragma solidity;
// ----
// ParserError 1684: (0-16): Found version pragma, but failed to parse it. Please ensure there is a trailing semicolon.