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 -1
View File
@@ -160,8 +160,10 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
vector<string> literals(_pragma.literals().begin() + 1, _pragma.literals().end());
SemVerMatchExpressionParser parser(tokens, literals);
auto matchExpression = parser.parse();
// An unparsable version pragma is an unrecoverable fatal error in the parser.
solAssert(matchExpression.has_value(), "");
static SemVerVersion const currentVersion{string(VersionString)};
if (!matchExpression.matches(currentVersion))
if (!matchExpression->matches(currentVersion))
m_errorReporter.syntaxError(
3997_error,
_pragma.location(),