mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixes wrong source location when reporting pragma solidity version conflicts.
This commit is contained in:
parent
556d11dae0
commit
bb28c8a877
@ -65,6 +65,8 @@ public:
|
|||||||
return make_shared<NodeType>(m_location, std::forward<Args>(_args)...);
|
return make_shared<NodeType>(m_location, std::forward<Args>(_args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SourceLocation const& location() const noexcept { return m_location; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser const& m_parser;
|
Parser const& m_parser;
|
||||||
SourceLocation m_location;
|
SourceLocation m_location;
|
||||||
@ -108,14 +110,15 @@ ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::parsePragmaVersion(vector<Token> const& tokens, vector<string> const& literals)
|
void Parser::parsePragmaVersion(SourceLocation const& _location, vector<Token> const& _tokens, vector<string> const& _literals)
|
||||||
{
|
{
|
||||||
SemVerMatchExpressionParser parser(tokens, literals);
|
SemVerMatchExpressionParser parser(_tokens, _literals);
|
||||||
auto matchExpression = parser.parse();
|
auto matchExpression = parser.parse();
|
||||||
static SemVerVersion const currentVersion{string(VersionString)};
|
static SemVerVersion const currentVersion{string(VersionString)};
|
||||||
// FIXME: only match for major version incompatibility
|
// FIXME: only match for major version incompatibility
|
||||||
if (!matchExpression.matches(currentVersion))
|
if (!matchExpression.matches(currentVersion))
|
||||||
fatalParserError(
|
m_errorReporter.fatalParserError(
|
||||||
|
_location,
|
||||||
"Source file requires different compiler version (current compiler is " +
|
"Source file requires different compiler version (current compiler is " +
|
||||||
string(VersionString) + " - note that nightly builds are considered to be "
|
string(VersionString) + " - note that nightly builds are considered to be "
|
||||||
"strictly less than the released version"
|
"strictly less than the released version"
|
||||||
@ -154,6 +157,7 @@ ASTPointer<PragmaDirective> Parser::parsePragmaDirective()
|
|||||||
if (literals.size() >= 2 && literals[0] == "solidity")
|
if (literals.size() >= 2 && literals[0] == "solidity")
|
||||||
{
|
{
|
||||||
parsePragmaVersion(
|
parsePragmaVersion(
|
||||||
|
nodeFactory.location(),
|
||||||
vector<Token>(tokens.begin() + 1, tokens.end()),
|
vector<Token>(tokens.begin() + 1, tokens.end()),
|
||||||
vector<string>(literals.begin() + 1, literals.end())
|
vector<string>(literals.begin() + 1, literals.end())
|
||||||
);
|
);
|
||||||
|
@ -73,7 +73,7 @@ private:
|
|||||||
|
|
||||||
///@{
|
///@{
|
||||||
///@name Parsing functions for the AST nodes
|
///@name Parsing functions for the AST nodes
|
||||||
void parsePragmaVersion(std::vector<Token> const& tokens, std::vector<std::string> const& literals);
|
void parsePragmaVersion(langutil::SourceLocation const& _location, std::vector<Token> const& _tokens, std::vector<std::string> const& _literals);
|
||||||
ASTPointer<PragmaDirective> parsePragmaDirective();
|
ASTPointer<PragmaDirective> parsePragmaDirective();
|
||||||
ASTPointer<ImportDirective> parseImportDirective();
|
ASTPointer<ImportDirective> parseImportDirective();
|
||||||
ContractDefinition::ContractKind parseContractKind();
|
ContractDefinition::ContractKind parseContractKind();
|
||||||
|
Loading…
Reference in New Issue
Block a user