Report meaningful error if parsing a version pragma failed

This commit is contained in:
Alex Beregszaszi
2020-12-18 11:50:37 +00:00
parent 8c455a1a99
commit b14a6a10cc
14 changed files with 45 additions and 8 deletions
+3 -2
View File
@@ -58,11 +58,12 @@ SemVerMatchExpression parseExpression(string const& _input)
}
auto expression = SemVerMatchExpressionParser(tokens, literals).parse();
BOOST_REQUIRE(expression.has_value());
BOOST_CHECK_MESSAGE(
expression.isValid(),
expression->isValid(),
"Expression \"" + _input + "\" did not parse properly."
);
return expression;
return *expression;
}
}
@@ -0,0 +1,3 @@
pragma solidity ^0^1;
// ----
// ParserError 5333: (0-21): Source file requires different compiler version (current compiler is ....
@@ -0,0 +1,3 @@
pragma solidity pragma;
// ----
// ParserError 1684: (0-23): Found version pragma, but failed to parse it. Please ensure there is a trailing semicolon.
@@ -0,0 +1,4 @@
pragma solidity #8.0.0;
// ----
// ParserError 6281: (16-17): Token incompatible with Solidity parser as part of pragma directive.
// ParserError 5333: (0-23): Source file requires different compiler version (current compiler is ....
@@ -0,0 +1,3 @@
pragma solidity (8.0.0);
// ----
// ParserError 1684: (0-24): Found version pragma, but failed to parse it. Please ensure there is a trailing semicolon.
@@ -0,0 +1,3 @@
pragma solidity 88_;
// ----
// ParserError 1684: (0-20): Found version pragma, but failed to parse it. Please ensure there is a trailing semicolon.
@@ -0,0 +1,3 @@
pragma solidity 0.4.3
// ----
// ParserError 2314: (22-22): Expected ';' but got end of source
@@ -0,0 +1,4 @@
pragma solidity 0.4.3
pragma abicoder v2;
// ----
// ParserError 1684: (0-41): Found version pragma, but failed to parse it. Please ensure there is a trailing semicolon.