mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Mark the empty version pragma as invalid
This commit is contained in:
parent
fdbb4d9a8f
commit
8edfa26f0a
@ -151,6 +151,9 @@ optional<SemVerMatchExpression> SemVerMatchExpressionParser::parse()
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
if (m_tokens.empty())
|
||||||
|
return nullopt;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <liblangutil/Token.h>
|
#include <liblangutil/Token.h>
|
||||||
|
#include <libsolutil/Assertions.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -84,9 +85,11 @@ struct SemVerMatchExpression
|
|||||||
class SemVerMatchExpressionParser
|
class SemVerMatchExpressionParser
|
||||||
{
|
{
|
||||||
public:
|
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))
|
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.
|
/// Returns an expression if it was parseable, or nothing otherwise.
|
||||||
std::optional<SemVerMatchExpression> parse();
|
std::optional<SemVerMatchExpression> parse();
|
||||||
|
@ -204,7 +204,7 @@ ASTPointer<PragmaDirective> Parser::parsePragmaDirective()
|
|||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expectToken(Token::Semicolon);
|
expectToken(Token::Semicolon);
|
||||||
|
|
||||||
if (literals.size() >= 2 && literals[0] == "solidity")
|
if (literals.size() >= 1 && literals[0] == "solidity")
|
||||||
{
|
{
|
||||||
parsePragmaVersion(
|
parsePragmaVersion(
|
||||||
nodeFactory.location(),
|
nodeFactory.location(),
|
||||||
|
3
test/libsolidity/syntaxTests/pragma/empty_version.sol
Normal file
3
test/libsolidity/syntaxTests/pragma/empty_version.sol
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user