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();
|
||||
|
||||
if (m_tokens.empty())
|
||||
return nullopt;
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <liblangutil/Token.h>
|
||||
#include <libsolutil/Assertions.h>
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
@ -86,7 +87,9 @@ class SemVerMatchExpressionParser
|
||||
public:
|
||||
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();
|
||||
|
@ -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(),
|
||||
|
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